Error on SignalR connection : UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED

Hi,
I start to develop a custom multiplayer server using SignalR.

The server part is ok and works with a custom console app client (connection and message exchange works).

When I implement this in Unity (2019.1.8f1 or 2019.2.0b7) i get this error :

There was an error opening the connection:System.Net.Http.HttpRequestException: An error occurred while sending the request β€”> System.Net.WebException: Error: TrustFailure (One or more errors occurred.) β€”> 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_FLAG_NOT_TRUSTED

There is only 5 results on google and no solution proposed, not even a clue on what to do.

Client code :

 var connection = new HubConnection("http://localhost:60791/");
    
        var myHub = connection.CreateHubProxy("ClientHub");

        connection.Start().ContinueWith(task => {
            if (task.IsFaulted)
            {
                Debug.LogError($"There was an error opening the connection:{task.Exception.GetBaseException()}");
            }
            else
            {
                Debug.Log("Connected");
            }

        }).Wait();

Server code :

app.UseSignalR(configure =>
            {
                configure.MapHub<ClientHub>("/ClientHub");
            });

Anyone has already deal with that ?

Thanks for your help :slight_smile:

that is a TLS handshake error, Unity can’t verify the certificate. Are you using a self signed certificate like, for example, the automatically generated one from the Dotnet runtime?

1 Like