The request was aborted: Failed to create a secure SSL / TLS channel. System.Net.WebException

I am using the PayPalStandard NopCommerce plugin. When I placed an order and paid for a paid plug-in after successful payment on PayPal, it is redirected to the merchants website. At this time, he gives an error:

The request was aborted: Failed to create a secure SSL / TLS channel.

I also use the Sandbox account for Paypal for testing.

It throws an error from this line:

var sw = new StreamWriter(req.GetRequestStream() 

Here is the code below:

 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); 
+5
source share
2 answers

I had the same sandbox problem (nvp), everything was fine, and then yesterday the message "Request was aborted: could not create a secure SSL / TLS channel." appeared.

I believe PayPal updated its endpoints on January 19/20, 2016 to use TSL 1.2 and HTTP 1.1.

To solve this problem, for .NET 4.5 and above, add the following line of code before calling WebRequest.Create ().

 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; 
+13
source

The answer that worked for us was indicated in the PayPal blog post, Notification of Upcoming Security Changes . There are a number of things listed in the message, but one that we did and that worked was the PayPal SDK Update . We updated using NuGet, and everything worked again.

0
source

Source: https://habr.com/ru/post/1241220/


All Articles