加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 请求已中止:无法创建SSL / TLS安全通道.System.

发布时间:2020-12-16 03:40:10 所属栏目:asp.Net 来源:网络整理
导读:我正在使用NopCommerce的PayPalStandard插件.当我下订单时在paypal成功付款后,使用paypalstandard插件付款,它会重定向到商家网站.那时它给出了错误: The request was aborted: Could not create SSL/TLS secure channel. 我也使用Paypal的Sandbox帐户进行测
我正在使用NopCommerce的PayPalStandard插件.当我下订单时在paypal成功付款后,使用paypalstandard插件付款,它会重定向到商家网站.那时它给出了错误:

The request was aborted: Could not create SSL/TLS secure channel.

我也使用Paypal的Sandbox帐户进行测试.

它从这一行抛出错误:

var sw = new StreamWriter(req.GetRequestStream()

这是下面的代码:

var req = (HttpWebRequest)WebRequest.Create(GetPaypalUrl());
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        req.ProtocolVersion = HttpVersion.Version10;

        string formContent = string.Format("cmd=_notify-synch&at={0}&tx={1}",_paypalStandardPaymentSettings.PdtToken,tx);
        req.ContentLength = formContent.Length;

        using (var sw = new StreamWriter(req.GetRequestStream(),Encoding.ASCII))
            sw.Write(formContent);

解决方法

我有同样的问题连接到沙盒(nvp),一切都很好,然后昨天消息“请求被中止:无法创建SSL / TLS安全通道.”出现了.

我相信PayPal在2016年1月19日更新了他们的终端,以使用TSL 1.2和HTTP 1.1.

要解决此问题,对于.NET 4.5及更高版本,在调用WebRequest.Create()之前添加以下代码行.

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读