Ignore SSL errors with signalR Core Client

前端 未结 2 890
挽巷
挽巷 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();
    

提交回复
热议问题