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

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

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

代码中当编译到 string response = service.Call(nvp.Encode()); 时就会报错,然后查阅了相关资料,当Paypal创建不安全因素的链接时候服务器就会阻止;
解决方案:在编译的代码前面加上
【Paypal开发中遇到请求被中止:|Paypal开发中遇到请求被中止: 未能创建 SSL/TLS 安全通道及解决方案】 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; 这句话就可以了。

转载于:https://www.cnblogs.com/BarryJames/p/6179738.html

    推荐阅读