0
点赞
收藏
分享

微信扫一扫

C# 请求被中止: 未能创建 SSL/TLS 安全通道”的原因及解决办法

_karen 2022-12-02 阅读 130


C# 请求被中止: 未能创建 SSL/TLS 安全通道”的原因及解决办法

代码前加上如下代码:

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;

或者

ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;

或者

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3
| SecurityProtocolType.Tls
| (SecurityProtocolType)0x300 //Tls11
| (SecurityProtocolType)0xC00; //Tls12


举报

相关推荐

0 条评论