Ignore SSL errors with signalR Core Client

前端 未结 2 871
挽巷
挽巷 2021-01-06 10:27

I\'m making an application that involves a website on localhost as a user interface with Asp.net Core and SignalR Core.

My problem is that I get an authentication ex

相关标签:
2条回答
  • 2021-01-06 11:13

    When connecting to HTTPS to ignore SSL certificate in SignalR Core client you should do this in HttpMessageHandlerFactory configs. Use HttpConnectionOptions in WithUrl method like this:

    connection = new HubConnectionBuilder()
    .WithUrl("https://localhost:443/MiniLyokoHub", (opts) =>
    {
        opts.HttpMessageHandlerFactory = (message) =>
        {
            if (message is HttpClientHandler clientHandler)
                // bypass SSL certificate
                clientHandler.ServerCertificateCustomValidationCallback +=
                    (sender, certificate, chain, sslPolicyErrors) => { return true; };
            return message;
        };
    })
    .Build();
    
    0 讨论(0)
  • 2021-01-06 11:26

    It seems that the SignalR Core Client is also subject to Https redirection Which is why it wouldn't connect to the http port.

    For my use case, I just had to disable it in Startup.cs

    0 讨论(0)
提交回复
热议问题