当前位置:   article > 正文

解决无法建立SSL / TLS安全通道(The request was aborted: Could not create SSL/TLS secure channel)的问题_ssl安全通道

ssl安全通道

解决无法建立SSL / TLS安全通道(The request was aborted: Could not create SSL/TLS secure channel)的问题

这个问题主要是没配置好SSL版本

在谷歌浏览器中打开该链接,按下F12,打开开发者工具,切换到Security选项卡,就可以看到了。这一串说明:
The connection to this site is encrypted and authenticated using TLS 1.2, ECDHE_RSA with P-256, and AES_128_GCM.
就是 TLS1.2
各SSL版本与C#代码的对应:

SSL/TLS版本对应C#代码
SSL 3ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
TLS 1.0ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
TLS 1.1ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11;
TLS 1.2ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

在发起https请求前使用以下代码

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
//如果编译器报错:未包含"Tls11"的定义,用以下代码,要解决这个报错也可以安装.net framework 4.5
//System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | (SecurityProtocolType)3072 | (SecurityProtocolType)768 | SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{   // 总是接受  
    return true;
});//验证服务器证书回调自动验证
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

原文链接:http://blog.albsz.cn/2020-11-05-sslTlsFail.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/830625
推荐阅读
相关标签
  

闽ICP备14008679号