Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Error on SignalR connection with localhost : UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED

Discussion in 'Multiplayer' started by Kolichikov, Oct 12, 2022.

  1. Kolichikov


    Jul 21, 2014
    Wasn't sure if I should resurrect this thread, but I have a similar issue with SignalR in Unity 2021.1.5f1.

    The code is similar, and I'm getting the above exception when connecting to localhost (see below).
    The code also works as expected when connecting to the staging/production servers.

    I also know that the code used to work with the dev server, and no changes have been made in the settings.
    It's a simple aspnetcore app, the web server settings have ssl enabled, anon authentication and windows authentication enabled.

    Is there a way to either sign localhost somehow or to tell Unity to ignore certificate issues on localhost (or alternatively, since I'm pretty weak with cert stuff, any other way to get around this issue)?

    Code setting up the connection:

    Code (CSharp):
    1. private void InitConnection()
    2.     {
    3.         Connection = new HubConnectionBuilder()
    4.             .WithUrl($"{Account.HomeAddress}/chatHub")
    5.             .Build();
    6.         Connection.ServerTimeout = TimeSpan.FromMinutes(5);
    7.         Connection.KeepAliveInterval = TimeSpan.FromSeconds(10);
    8.         Debug.Log(Account.HomeAddress);
    9.         Connection.Closed += async (error) =>
    10.         {
    11.             await Task.Delay(UnityEngine.Random.Range(0, 5) * 1000);
    12.             closed = true;
    13.             await Connection.StartAsync();
    14.         };
    15.     }
    Code where the exception is thrown, called pretty much after the above, after some Connection.On calls are registered.
    Code (CSharp):
    2. if (Connection.State != HubConnectionState.Connected)
    3.             {
    4.                 await Connection.StartAsync();
    5.             }