Trying to connect to a secure websocket (wss scheme) on localhost throws the following error:
Handshake failed - error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED
My connection code:
async void Start()
{
DontDestroyOnLoad(gameObject);
clientWebSocket = new ClientWebSocket();
clientWebSocket.Options.AddSubProtocol("Tls");
Debug.Log("[WS]:Attempting connection.");
try
{
Uri uri = new Uri("wss://localhost:8080/ws/chat");
await clientWebSocket.ConnectAsync(uri, CancellationToken.None);
if (clientWebSocket.State == WebSocketState.Open)
{
Debug.Log("Input message ('exit' to exit): ");
Listen();
StartCoroutine(SendTest(10));
}
Debug.Log("[WS][connect]:" + "Connected");
}
catch (Exception e)
{
Debug.Log("[WS][exception]:" + e.Message);
if (e.InnerException != null)
{
Debug.Log("[WS][inner exception]:" + e.InnerException.Message);
if (e.InnerException.InnerException != null)
{
Debug.Log("[WS][inner exception][inner exception]:" + e.InnerException.InnerException.Message);
}
}
}
Debug.Log("End");
}
Everything works fine with the ws scheme.
Any suggestions on how to fix this would be appreciated!