绕过.net核心中的无效SSL证书 [英] bypass invalid SSL certificate in .net core

查看:163
本文介绍了绕过.net核心中的无效SSL证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个需要连接到https站点的项目.每次连接时,我的代码都会引发异常,因为该站点的证书来自不受信任的站点.有没有一种方法可以绕过.net core http中的证书检查?

I am working on a project that needs to connect to an https site. Every time I connect, my code throws exception because the certificate of that site comes from untrusted site. Is there a way to bypass certificate check in .net core http?

我从.NET的早期版本中看到了此代码.我想我只需要这样的东西.

I saw this code from previous version of .NET. I guess I just need something like this.

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

.net Core不支持

推荐答案

ServicePointManager.ServerCertificateValidationCallback.

ServicePointManager.ServerCertificateValidationCallback isn't supported in .Net Core.

目前的情况是 一种新的 ServerCertificateCustomValidationCallback 方法,用于即将出现的4.1.* System.Net.Http合同(HttpClient). .NET Core团队现在正在最终确定4.1合同.您可以在此处github上阅读

Current situation is that it will be a a new ServerCertificateCustomValidationCallback method for the upcoming 4.1.* System.Net.Http contract (HttpClient). .NET Core team are finalizing the 4.1 contract now. You can read about this in here on github

您可以通过直接在CoreFx或MYGET提要中使用源来试用System.Net.Http 4.1的预发布版本: https://dotnet.myget.org/gallery/dotnet-core

You can try out the pre-release version of System.Net.Http 4.1 by using the sources directly here in CoreFx or on the MYGET feed: https://dotnet.myget.org/gallery/dotnet-core

当前 Github上的WinHttpHandler.ServerCertificateCustomValidationCallback 定义

这篇关于绕过.net核心中的无效SSL证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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