微信退款时候报”请求被中止: 未能创建 SSL/TLS 安全通道“或”The request was aborted: Could not create SSL/TLS secure channel“的错误

原文: 微信退款时候报”请求被中止: 未能创建 SSL/TLS 安全通道“或”The request was aborted: Could not create SSL/TLS secure channel“的错误

如题,英文中文表述的是一个意思

退款测试在我本机测试一切都是正常的,但是发布到了服务器就报这样的一个错啦

但是无论百度或者google或者bing,你能够搜索到的结果都很类似,综合起来就是加这样一些代码,如下

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
ServicePointManager.DefaultConnectionLimit = 9999;

把代码添加到WebRequest.Create(url)之前去。

按照别人的意思加了,然而这并没有什么卵用,错误依旧照常,然后继续查,然后又有人给出了委托回调的方式,如下

ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) { //直接确认,否则打不开   return true; }

第一行是调用,第二行是实现,按照别的意思,检查了下代码,发现在原来的代码里面本身就有这些代码

然后再某个巧合时间看到了另外一种方式,大意就是我们iis设置错误导致的错误

解决方法是:IIS-》应用程序池-》高级设置-》进程模块-》加载用户配置文件,设置为True就可以了

按照别人提供的思路,设置完毕,再实验,果然ok啦,尼玛,坑啊,那为啥我本机就是可以的呢?马上检查下自己本机的iis配置

我擦发现我本机默认的就是开的,尼玛啊,坑死我啦!

猜你喜欢

转载自www.cnblogs.com/lonelyxmas/p/9339760.html