使用signalR Core Client忽略SSL错误 [英] Ignore SSL errors with signalR Core Client

查看:416
本文介绍了使用signalR Core Client忽略SSL错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个涉及localhost上的网站的应用程序,作为带有Asp.net Core和SignalR Core的用户界面.

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

我的问题是启动连接时出现身份验证异常. 我知道发生这种情况是因为我还没有运行dotnet dev-certs https --trust.但是我不能指望普通用户运行此命令或根本没有安装dotnet SDK.

My problem is that I get an authentication exception when starting the connection. I know this happens because I haven't ran dotnet dev-certs https --trust. But I can't expect an average user to run this command or have the dotnet SDK installed at all.

我尝试使用

ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;

在我的Startup.cs中(以及其他位置,但是我知道这是全局设置.无论如何,它是在HubConnection之前执行的) 无济于事. 我还尝试设置一个新的HttpMessageHandlerFactory,但是文档告诉我这不会影响Websockets.

in my Startup.cs (and other places, but I understand that it's a global setting. in any case it was executed before the HubConnection) to no avail. I also tried setting a new HttpMessageHandlerFactory, but the documentation tells me that doesnt affect Websockets.

我不相信是一种解决方案,因为我不能使用其他HttpClient(除非我弄错了)

I don't believe this is a solution, because I can't use a different HttpClient (unless I'm mistaken)

如您所见,我根本没有连接到https:

As you can see, I'm not connecting to https at all:

connection = new HubConnectionBuilder().WithUrl("http://localhost:5000/MiniLyokoHub" ).Build();

所以我不明白为什么它甚至试图获得证书.

So I don't see why it is even trying to get the certificate.

这是完整的错误: https://pastebin.com/1ELbeWtc

如何解决这个问题? 我不需要证书,因为用户将连接到自己的本地主机. 还是我不应该使用websockets?

How can I get around this issue? I don't need a certificate, since the user will be connecting to their own localhost. Or should I just not use websockets?

推荐答案

SignalR Core Client似乎也受 Https重定向的约束. 这就是为什么它无法连接到http端口的原因.

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

对于我的用例,我只需要在Startup.cs中将其禁用

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

这篇关于使用signalR Core Client忽略SSL错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆