Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue to use TLS 1.2 in .NET Framework 4.0

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?

like image 664
omkar patade Avatar asked Oct 17 '25 07:10

omkar patade


1 Answers

According to this post:

.NET 4.0 supports up to TLS 1.0 while .NET 4.5 supports up to TLS 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, replacing System.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
like image 144
VMAtm Avatar answered Oct 21 '25 05:10

VMAtm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!