PayPal – The request aborted could not create SSL-TLS connection – Resolved

PayPal – The request aborted could not create SSL-TLS connection – Resolved

To resolve the above issue and the following warning

You must write ContentLength bytes to the request stream before calling [Begin]GetResponse.

Include following

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

in function

 public string HttpCall(string NvpRequest) //CallNvpServer

The function will look as follows

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);

            System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

            HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
            objRequest.Timeout = Timeout;
            objRequest.Method = “POST”;
            objRequest.ContentLength = strPost.Length;

Leave a Reply

Your email address will not be published. Required fields are marked *