FomTarro / vts-heartrate

Heartrate Plugin for VTube Studio
MIT License
7 stars 1 forks source link

HypeRate TSL handshake Failure #17

Closed FomTarro closed 2 years ago

FomTarro commented 2 years ago

Recently, HypeRate connection is failing due to Unity rejecting the TLS handshake.

10/14/2022 8:34:40 AM|Fatal|WebSocket.connect|WebSocketSharp.WebSocketException: An error has occurred during a TLS handshake. ---> System.AggregateException: One or more errors occurred. ---> System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> Mono.Security.Interface.TlsException: Handshake failed - error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_NOT_DONE
                              at Mono.Unity.Debug.CheckAndThrow (Mono.Unity.UnityTls+unitytls_errorstate errorState, Mono.Unity.UnityTls+unitytls_x509verify_result verifyResult, System.String context, Mono.Security.Interface.AlertDescription defaultAlert) [0x00036] in <ef151b6abb5d474cb2c1cb8906a8b5a4>:0 
                              at Mono.Unity.UnityTlsContext.ProcessHandshake () [0x00082] in <ef151b6abb5d474cb2c1cb8906a8b5a4>:0 
                              at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status) [0x0003e] in <ef151b6abb5d474cb2c1cb8906a8b5a4>:0 
                              at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus)
                              at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00006] in <ef151b6abb5d474cb2c1cb8906a8b5a4>:0 
                              at Mono.Net.Security.AsyncProtocolRequest+<ProcessOperation>d__24.MoveNext () [0x000ff] in <ef151b6abb5d474cb2c1cb8906a8b5a4>:0 
                            --- End of stack trace from previous location where exception was thrown ---
                              at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <eae584ce26bc40229c1b1aa476bfa589>:0 
                              at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <eae584ce26bc40229c1b1aa476bfa589>:0 
                              at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <eae584ce26bc40229c1b1aa476bfa589>:0 
                              at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <eae584ce26bc40229c1b1aa476bfa589>:0 
                              at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <eae584ce26bc40229c1b1aa476bfa589>:0 
                              at Mono.Net.Security.AsyncProtocolRequest+<StartOperation>d__23.MoveNext () [0x0008b] in <ef151b6abb5d474cb2c1cb8906a8b5a4>:0 
                               --- End of inner exception stack trace ---
                              at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <eae584ce26bc40229c1b1aa476bfa589>:0 
                              at Mono.Net.Security.MobileAuthenticatedStream+<ProcessAuthentication>d__47.MoveNext () [0x00254] in <ef151b6abb5d474cb2c1cb8906a8b5a4>:0 
                               --- End of inner exception stack trace ---
                              at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <eae584ce26bc40229c1b1aa476bfa589>:0 
                              at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <eae584ce26bc40229c1b1aa476bfa589>:0 
                              at System.Threading.Tasks.Task.Wait () [0x00000] in <eae584ce26bc40229c1b1aa476bfa589>:0 
                              at Mono.Net.Security.MobileAuthenticatedStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, System.Boolean checkCertificateRevocation) [0x0000d] in <ef151b6abb5d474cb2c1cb8906a8b5a4>:0 
                              at System.Net.Security.SslStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, System.Boolean checkCertificateRevocation) [0x00006] in <ef151b6abb5d474cb2c1cb8906a8b5a4>:0 
                              at WebSocketSharp.WebSocket.setClientStream () [0x00100] in <38d3cef14c5a4fc9a92de0991034bc1a>:0 
                               --- End of inner exception stack trace ---
                              at WebSocketSharp.WebSocket.setClientStream () [0x0011d] in <38d3cef14c5a4fc9a92de0991034bc1a>:0 
                              at WebSocketSharp.WebSocket.doHandshake () [0x00001] in <38d3cef14c5a4fc9a92de0991034bc1a>:0 
                              at WebSocketSharp.WebSocket.connect () [0x0004d] in <38d3cef14c5a4fc9a92de0991034bc1a>:0 
Main socket closing: 1015, 'An exception has occurred while connecting.', False 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Switching to a plain ws:// connection from wss:// seems to remediate this (for me), but further user testing is needed. Also, an issue with reconnection has been discovered causing the app to hang when trying to reconnect using the same socket reference.

10/14/2022 9:48:29 AM|Error|WebSocket.SendAsync|This operation isn't available in: connecting
Main socket open! 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Main socket closing: 1005, '', True 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Disconnected from the HypeRate socket 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Main socket error... 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

'An error has occurred in sending data.',  
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

An error occured while connecting to the HypeRate socket... 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Attempting to reconnect to HypeRate socket... 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Connected to HypeRate socket 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

10/14/2022 9:48:29 AM|Error|WebSocket.SendAsync|This operation isn't available in: connecting
Main socket open! 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)