简体   繁体   English

为 SignalR javascript 客户端构建 URL 时忽略自签名证书

[英]Ignore Self-Signed certificate when building Url for SignalR javascript client

Is there a way to bypass a self-signed certificate when building the Url on signalR.HubConnectionBuilder() of JavaScript client?在 JavaScript 客户端的 signalR.HubConnectionBuilder() 上构建 Url 时,有没有办法绕过自签名证书?

I found this can be done and work perfectly in C# client with the following code我发现这可以使用以下代码在 C# 客户端中完成并完美运行

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.但是,我正在 JavaScript 客户端中搜索。

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.在尝试建立连接之前添加上面的行在 NodeJS 中为我​​解决了这个问题。 This is for my developer setup.这是我的开发人员设置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 具有本地 IP 的设备的自签名证书 - Self-signed certificate for device with local IP OnCertificateValidated 未运行 - 自签名证书客户端身份验证 - ASP.NET Core 和 Kestrel - OnCertificateValidated not running - Self-Signed Certificate Client Authentication - ASP.NET Core and Kestrel 如何使用自签名客户端证书修复 asp.net core 3.1 中的 RevocationStatusUnknown - How to fix RevocationStatusUnknown in asp.net core 3.1 with self-signed client certificate IdentityServer4 中的 AddSigningCredential - 自签名或来自证书颁发机构 - AddSigningCredential in IdentityServer4 - Self-signed or from a certificate authority 如何生成不会在浏览器中触发警告的自签名证书? - How to generate a self-signed certificate that does not trigger warnings in browsers? ASP.NET 核心 Web API 客户端不信任 Identity Server 实例使用的自签名证书 - ASP.NET Core Web API client does not trust self-signed certificate used by the Identity Server instance Self Hosted Asp Net Core Web 服务器,使用自签名证书进行客户端身份验证 - Self Hosted Asp Net Core Web server, client authentication with self-signed certificates Microsoft.AspNet.Hosting:如何添加自签名SSL证书 - Microsoft.AspNet.Hosting: How to add a self-signed SSL certificate 让 Kestrel 使用 Ubuntu 的自签名证书 - Make Kestrel use Ubuntu's self-signed certs Windows不接受自签名SSL证书 - Windows not accepting Self Signed SSL Certificate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM