Paypal开发中遇到请求被中止: 未能创建 SSL/TLS 安全通道及解决方案

   最近在基于ASP.NET上开发了Paypal支付平台,在ASP.NET开发的过程中没有遇到这个问题,但是引用到MVC开发模式中的时候就出现了“未能创建 SSL/TLS 安全通道及解决方案”的问题;

 1         /// <summary>
 2         /// 发送请求
 3         /// </summary>
 4         /// <param name="nvp"></param>
 5         /// <returns></returns>
 6         private static NVPCodec SendExpressCheckoutCommand(NVPCodec nvp)
 7         {
 8             NVPCallerServices service = InitializeServices();
 9             string response = service.Call(nvp.Encode());
10 
11             NVPCodec responsenvp = new NVPCodec();
12             responsenvp.Decode(response);
13             return responsenvp;
14 
15         }

代码中当编译到 string response = service.Call(nvp.Encode());时就会报错,然后查阅了相关资料,当Paypal创建不安全因素的链接时候服务器就会阻止;

解决方案:在编译的代码前面加上

 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;这句话就可以了。

 

posted @ 2016-12-14 16:08  毁歌掌萌人  阅读(909)  评论(0编辑  收藏  举报