使用signalR Core Client忽略SSL错误

编程入门 行业动态 更新时间:2024-10-21 09:25:49
本文介绍了使用signalR Core Client忽略SSL错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I'm making an application that involves a website on localhost as a user interface with Asp 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("localhost:5000/MiniLyokoHub" ).Build();

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

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

这是完整的错误: pastebin/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错误

本文发布于:2023-11-07 22:54:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1567664.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   Core   signalR   SSL   Client

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!