I got TLS 1.0 disabled. So we are trying to use TLS 1.2 in our .Net application which is using .Net Framework 4.0.
I have added the code for this at the start
System.Net.ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
It works perfectly on my local system.
But i am not sure why its not working when I deploy the code on server (Windows Server 2008 R2). I checked everything. .Net framework is present on server. But still its giving the same issue on server only.
Is there anything I'm missing here?
According to this post:
.NET 4.0
supports up toTLS 1.0
while.NET 4.5
supports up toTLS 1.2
However, an application targeting
.NET 4.0
can still support up to TLS 1.2 if .NET 4.5 is installed in the same environment..NET 4.5
installs on top of.NET 4.0
, replacingSystem.dll
.
So basically you need to upgrade your server to .Net 4.5
to enable TLS 1.2
.
Also, you can simplify your code and make it more readable:
using System.Net;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
Related MSDN articles:
SecurityProtocolType
enum for .Net 4.0 (no Tls12
member here)SecurityProtocolType
enum for current .Net