小程序APPID :wx65c791ad99e4d00b
这个问题已经好久了,过程如下,程序开发完后,按网上给例子代码,小程序在测试服务器上可以正常退款,在生产服务器上退款失败, 提示:”“请求被中止: 未能创建 SSL/TLS 安全通道。”,支付都是正常的。退款是双验证,退款一直就是失败。
生产环境:Windows Sever 2012 R2 Datacenter, IIS6.2,.Net 4.6
出错代码行:WebResponse rep = req.GetResponse() //见下面代码最后一行。
代码:
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls; //协议等级,解决“未能创建 SSL/TLS 安全通道。”的问题
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback(CheckValidationResult);
ServicePointManager.DefaultConnectionLimit = 9999; //协议等级,解决“未能创建 SSL/TLS 安全通道。”的问题
X509Certificate cer = new X509Certificate(local, ps);
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
req.ClientCertificates.Add(cer);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
//req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36";
byte[] byteData = Encoding.UTF8.GetBytes(parameter);
using (Stream reqStream = req.GetRequestStream())
{
reqStream.Write(byteData, 0, byteData.Length);
}
using (WebResponse rep = req.GetResponse()) //这行代码出错!!!
你好,请参考帖子:https://developers.weixin.qq.com/community/develop/doc/00080e83240080361f085ae6656000?_at=1598430176679
看看是不是同个问题