System.Net.WebException: 请求被中止: 未能创建 SSL/TLS 安全通道。
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
在 System.Net.HttpWebRequest.GetRequestStream()
在 WxPayLib.WxPay.Send_post(String xml, Int32 code) 位置 C:\Users\admin\Documents\NewsApp\NewsApp.Libs\WxPayLib\WxPay.cs:行号 243
在调试微信付款的时候一直报这个错。本地能跑得通,但上传到服务器就一直报错,网上的答案千篇一律都叫你
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
这么搞,但是实践证明是行不通的,坑呀。正确姿势如下:
先下载http://www.microsoft.com/en-us/download/details.aspx?id=19801
这个工具
然后安装,再打开cmd 运行如下命令
cd C:\Program Files (x86)\Windows Resource Kits\Tools winhttpcertcfg -g -c LOCAL_MACHINE\MY -s "MM" -a "Everyone"
其中 -s 是subjectstr 用于模糊匹配证书的一个字符串,我们这里用微信的证书MM