3
// _url = wss://test.com:8080/action
// _url = wss//127.0.0.1:8080/action
await _connectCws.ConnectAsync(_uri, _connectCts.Token).ConfigureAwait(false);

If I use the above link it works fine, but if I use the following link it will cause this error

TlsException: Handshake failed - error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED

actually, test.com is pointing to 127.0.0.1

I set up a websocket server locally by ws of nodejs, and use the certificate created by OpenSSL

I prefer to use IP so I can connect to the server on another device

I tried to add ServicePointManager. SecurityProtocol = SecurityProtocolType. Tls12; ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };, but it don't work

twowind
  • 31
  • 4
  • This problem seems to be relevant, maybe it can help https://stackoverflow.com/questions/59945581/unity-tlsexception-handshake-failed-unitytls-x509verify-flag-not-trusted – andrelange91 Jun 24 '22 at 12:30
  • I have read this post. I used the local self-signed certificate. I checked ServerCertificateValidationCallback, it doesn't seem to work. – twowind Jun 25 '22 at 03:49
  • Did you find the solution to your problem @twowind ? I'm struggling with the same issue. – Robert van der Spek Dec 13 '22 at 16:34
  • @Robert van der Spek, This is a problem I didn't get to solve before. Now I seem to be able to surmise where I am having the problem. It was due to the domain name (test.com) based CA I was using at the time, and would have had to use that domain for access. You can either bind to this domain for the ip in the code or install an IP based CA. i can only give this idea, if you still can't solve it, you can go into the details of how HTTPS works. – twowind Dec 21 '22 at 04:36
  • Thanks @twowind meanwhile I actually solved it by using the entire keychain for my domain. Apparently unity apps don't handle TLS1.2 anymore (or I couldn't find a way to force it to anyway.) – Robert van der Spek Dec 21 '22 at 07:59

0 Answers0