解决基础连接已经关闭: 未能为 SSL/TLS 安全通道建立信任关系。

如果IIS上没有绑定证书,那么Request请求会出现 “未能为 SSL/TLS 安全通道建立信任关系” 这个错误;

解决办法:在请求前面加上两行代码

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

 

posted on 2020-11-02 09:29  阿里正正  阅读(4727)  评论(0编辑  收藏  举报

导航