gpt4 book ai didi

asp.net-mvc - 请求被中止 : Could not create SSL/TLS secure channel. System.Net.WebException

转载 作者:太空宇宙 更新时间:2023-11-03 15:40:50 25 4
gpt4 key购买 nike

我正在使用 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 日至 20 日更新了他们的端点以使用 TSL 1.2 和 HTTP 1.1。

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

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

关于asp.net-mvc - 请求被中止 : Could not create SSL/TLS secure channel. System.Net.WebException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34945002/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com