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

Jayasuriya, Pathum 26 Reputation points
2022-11-03T10:26:37.777+00:00

Hi All,

This Application is based on .NET framework 4.5 and application works fine, but it has a function that calls external API for SMS gateway, that's where this error is coming.
I have followed all answers for this question, but no luck.

This application is hosted on Windows Server 2012 R2, and it is TLS 1.2 enabled by default.
I also double check whether it's Application problem or Server itself by calling the SMS GW API thourhg postman inside Serever and it works fine.

My problem is eventhough i rebuild the Application with .NET target framework to 4.7 still this error comes whenever application calling SMS GW API.

full error message

System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.  
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)  
   at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)  
   --- End of inner exception stack trace ---  
Developer technologies | .NET | .NET Runtime
Windows for business | Windows Server | Devices and deployment | Configure application groups
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,766 Reputation points
    2022-11-08T09:59:56.807+00:00

    Hi. Thank you for your question and reaching out.

    You must start by include this:

    // using System.Net;
    ServicePointManager.Expect100Continue = true;
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
    // Use SecurityProtocolType.Ssl3 if needed for compatibility reasons

    --------------------------------------------------------------------------------------------------------------------------------------------------

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.