3

I am trying to integrate paypal into a web application and I've not been successful. I have tried loads of things but I keep coming back to one particular error. I am now trying to use the paypal integration wizard, and when I get the code that is provided, I get an error that says: The request was aborted: Could not create SSL/TLS secure channel.

This is the code:

public string HttpCall(string NvpRequest) //CallNvpServer
{
    string url = pendpointurl;

    //To Add the credentials from the profile
    string strPost = NvpRequest + "&" + buildCredentialsNVPString();
    strPost = strPost + "&BUTTONSOURCE=" + HttpUtility.UrlEncode( BNCode );

    HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
    objRequest.Timeout = Timeout;
    objRequest.Method = "POST";
    objRequest.ContentLength = strPost.Length;
    StreamWriter myWriter = new StreamWriter(objRequest.GetRequestStream());

The error occurs on the last line, on the objRequest.GetRequestStream()

I tried looking it up on google but I didn't find anything that worked for me. Does anybody know what I can do to fix this?

LMS
  • 43
  • 2
  • 5
  • have you checked [this](http://stackoverflow.com/questions/34939523/the-request-was-aborted-could-not-create-ssl-tls-secure-channel-sandbox-account) ? – cableload Apr 12 '16 at 13:37
  • I have, yes. It kind of worked, but then I got an error saying: the request was aborted. the request was canceled – LMS Apr 12 '16 at 13:49
  • Tried this http://stackoverflow.com/questions/2859790/the-request-was-aborted-could-not-create-ssl-tls-secure-channel ? – Hrvoje Hudo Apr 12 '16 at 15:07
  • I have this exact problem. Did you ever find a solution? – Kyle Humfeld Jul 20 '16 at 23:05

2 Answers2

5

Add the following code to your global.asax.cs Application_Started method or before calling the (HttpWebRequest)WebRequest.Create(url);

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

This was caused because PayPal are changing their encryption to TLS instead of SSL. This has already been updated on the Sandbox environments but not yet on the live.

Read more: https://devblog.paypal.com/upcoming-security-changes-notice/

Kevin Farrugia
  • 6,431
  • 4
  • 38
  • 61
0

I am here with the exact same problem on a different site, but for me this did not work, but the following did:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
Rick
  • 1