0

I have an ASP.NET MVC application that makes call to an external service that support only TLS1.2 protocol.

When the code makes the call I get this error:

System.Net.Http.HttpRequestException HResult=0x80131500 Message=An error occurred while sending the request.

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

It seems that my side (the client one) does not support TLS1.2.

My question are:

  1. How can I enable TLS1.2 in a .NET 4.7 application?
  2. Is it something that I can force in the code?
  3. Consider that the app will be deployed on an Azure APP SERVICE, so I cannot manage IIS settings machine registry stuff.

Thanks, \sergio

1 Answer 1

1

I think you can do this in code level with below line before calling web service

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

If you are not sure of the protocol you can use below

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
Sign up to request clarification or add additional context in comments.

3 Comments

Unfortunately this does not work for me. I've tried to add the line System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 both before calling the web service, and in the Global.asax Application_Start method, but the result is the same "The request was aborted: Could not create SSL/TLS secure channel."
To adds more, the code calling the external web service works fine wheter I run it from my win10 laptop, while it fails when run from a Windows Server 2012 r2. Clearly Win10 has a different TLS1.2 support compared to the WindowsServer 2012R2 one. Maybe I have to add something to the WindowsServer 2012R2 to support TLS12?
check This

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.