Visa Developer Community

Regular Visitor

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

Hello Guys, I keep getting the error The request was aborted: Could not create SSL/TLS secure channel. when i try call the service. however it works fine when i call the service using soupUI. I am using C# downloaded code to test Visa Direct API.

 

 

8 REPLIES 8
Regular Visitor

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

should use TLS 1.2

 

 

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Visa Dev Moderator

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

Hi @NdavheZitha,

 

Please review the Visa Direct documentation via this link - https://developer.visa.com/capabilities/visa_direct/docs

 

In particular, see the top few paragraphs that are shaded in yellow that discuss the requirements to use Visa Direct.

 

After having read the documentation, if you meet those requirements, then please click through the link in those paragraphs to the Visa Direct Program Implementation Questionnaire, fill it out, and submit to the email address listed on that form. Please let us know if you have other questions.

 

Thanks,
Diana

Highlighted
Helper

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

Hi 

 

Did you find the solution for the above error. I am also facing the same issue where I am getting error saying "The request was aborted: Could not create SSL/TLS secure channel." I have tried all the options but no luck.

 

Its working fine with SOAP UI, but when I try with .NET its not working. Can you please help me on this issue.?

 

 string requestURL = "https://sandbox.api.visa.com/vdp/helloworld";// ConfigurationManager.AppSettings["visaUrl"] + path;
            string userId =  ConfigurationManager.AppSettings["userId"];
            string password =  ConfigurationManager.AppSettings["password"];
            string certificatePath = ConfigurationManager.AppSettings["cert"];
            string certificatePassword = ConfigurationManager.AppSettings["certPassword"];
            string statusCode = "";
            LogRequest(requestURL, requestBodyString);
            // Create the POST request object
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            HttpWebRequest request = WebRequest.Create(requestURL) as HttpWebRequest;
            request.Method = method;

            if (method.Equals("POST") || method.Equals("PUT"))
            {
                request.ContentType = "application/json";
                request.Accept = "application/json";
                // Load the body for the post request
                var requestStringBytes = Encoding.UTF8.GetBytes(requestBodyString);
                request.GetRequestStream().Write(requestStringBytes, 0, requestStringBytes.Length);
            }
            if (headers != null)
            {
                foreach (KeyValuePair<string, string> header in headers)
                {
                    request.Headers[header.Key] = header.Value;
                }
            }
           
            // Add headers
            request.Headers["Authorization"] = GetBasicAuthHeader(userId, password);
           request.Headers["ex-correlation-id"] = GetCorrelationId();
           
            // Add certificate
            var certificate = new X509Certificate2("C:\\OpenSSL\\bin\\BillPay.p12", "test");
            request.ClientCertificates.Add(certificate);
            request.PreAuthenticate = true;
           
            try
            {
               
                // Make the call
                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                    LogResponse(testInfo, response);
                    statusCode = response.StatusCode.ToString();
                }
            }
            catch (WebException e)
            {
                if (e.Response is HttpWebResponse)
                {
                    HttpWebResponse response = (HttpWebResponse)e.Response;
                    LogResponse(testInfo, response);
                    statusCode = response.StatusCode.ToString();
                }
            }
 
 

Thanks,

Ramesh

Visa Dev Moderator

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

Hi @ramesharige,

 

If you are using C# please make a p12 file using the commands from github
https://github.com/visa/SampleCode/tree/master/vdp-c-sharp#usage

 

You can also refer to manual
https://github.com/visa/SampleCode/wiki/Manual

 

The problem could be that you have made a wrong p12 certificate.

 

                              

Thanks,
Diana

Helper

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

Thanks those links helped me. So we need to make sure to generate certificate differently if we are using c#.net

Helper

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

Hi Dana

 

Thanks for your URLs, It worked like charm when I followed those instructions.

It was not working when I tried first time. Again I tried to generate with help of your URL's it worked. Thanks alot.

 

Thanks,

Ramesh

New Contributor

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

Those links no longer work, do you have an updated url?

Visa Dev Moderator

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

Hello @appdevelopers

 

Due to some security issues, we are not able to upload the code on GitHub. VDP engineering team is workin on this but meanwhille, you can create a project on VDP and get the sample code from the Test Data of the project. 

 

Please follow the steps in the “Get Started” link below to register and create a Visa Developer application.  

https://developer.visa.com/pages/working-with-visa-apis 

 

This guide walks you through the key steps for application creation, credentials, and connection validation.  

 

If you are ready after testing your App in sandbox, send us a production request and we will evaluate your Application and other credentials.   

 

Let me know if you have any additional questions. 

 

Thank you, 

Vaibhav