Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am using PayPalStandard plugin of NopCommerce. When I placed the order & make payment with paypalstandard plugin after successful payment on paypal, it redirects to merchants site. At that time it gives error:

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

Also I am using Sandbox account of Paypal for testing.

It throws error from this line:

var sw = new StreamWriter(req.GetRequestStream()

Here is 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);
like image 906
chitra Avatar asked Jan 22 '16 10:01

chitra


People also ask

Why the request was aborted could not create SSL TLS secure channel?

The error “The request was aborted: Could not create SSL/TLS secure channel.” can happen during any download HTTP request. This error generally will correspond to firewalls, proxies or DNS filtering blocking the connection or an SSL/TLS cipher misconfiguration.

Can't create SSL TLS secure channel IIS?

However, the "Could not create SSL/TLS secure channel" error usually means that there's something wrong with the server certificate, e.g. the certificate is for a different hostname, or otherwise invalid, or not trusted etc.

Can't create SSL TLS secure channel excel?

To solve this error, you must ensure . NET Framework is using SSL/TLS 1.1 on Windows settings. There are two options for solving this: editing the Windows registry or reinstalling the . NET Framework.


1 Answers

I had the same issue connecting to sandbox(nvp), everything was fine then yesterday the message "The request was aborted: Could not create SSL/TLS secure channel." appeared.

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

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

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
like image 57
nqynik Avatar answered Oct 10 '22 01:10

nqynik