Sergio Armenia
Sergio Armenia

Reputation: 123

Broken TLS connection from an ASP.NET MVC application

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

Upvotes: 0

Views: 370

Answers (1)

Nagib Mahfuz
Nagib Mahfuz

Reputation: 833

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;

Upvotes: 1

Related Questions