4

Is there a way to bypass a self-signed certificate when building the Url on signalR.HubConnectionBuilder() of JavaScript client?

I found this can be done and work perfectly in C# client with the following code

connection = new HubConnectionBuilder()
.WithUrl("https://localhost:443/hub", (opts) =>
{
    opts.HttpMessageHandlerFactory = (message) =>
    {
        if (message is HttpClientHandler clientHandler)
            // bypass SSL certificate
            clientHandler.ServerCertificateCustomValidationCallback +=
                (sender, certificate, chain, sslPolicyErrors) => { return true; };
        return message;
    };
})
.Build();

But, I'm searching for exactly that in JavaScript client.

David Silwal
  • 581
  • 5
  • 18

1 Answers1

1
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0; // Disabling certificate verification

Adding the above line before attempting to make the connection solved it for me in NodeJS. This is for my developer setup.