Re: The request was aborted: Could not create SSL/TLS secure channel.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! Go to Solution
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: The request was aborted: Could not create SSL/TLS secure channel.
should use TLS 1.2
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 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.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);
}
{
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: The request was aborted: Could not create SSL/TLS secure channel.
Those links no longer work, do you have an updated url?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried different openssl commands to generate the p12 certificate and found that the following works for me:
> openssl pkcs12 -export -in cert.pem -inkey "privateKey.pem" -out myProject_keyAndCertBundle.p12
See my post on a different thread for more information:
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: The request was aborted: Could not create SSL/TLS secure channel.
Hey @bstricker,
That's good news. Thanks for sharing the command that got you successful results. It's greatly appreciated.