TLS 1.2 in .NET Framework 4.0
Solution 1:
If you are not able to add a property to system.net
class library.
Then, add in Global.asax file:
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; //TLS 1.2
ServicePointManager.SecurityProtocol = (SecurityProtocolType)768; //TLS 1.1
And you can use it in a function, at the starting line:
ServicePointManager.SecurityProtocol = (SecurityProtocolType)768 | (SecurityProtocolType)3072;
And, it's being useful for STRIPE
payment gateway, which only supports TLS 1.1, TLS 1.2.
EDIT:
After so many questions on .NET 4.5 is installed on my server or not... here is the screenshot of Registry
on my production server:
I have only .NET framework 4.0 installed.
Solution 2:
Make the following changes in your Registry and it should work:
1.) .NET Framework strong cryptography registry keys
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001
2.) Secure Channel (Schannel) TLS 1.2 registry keys
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2]
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"DisabledByDefault"=dword:00000000
"Enabled"=dword:00000001
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"DisabledByDefault"=dword:00000000
"Enabled"=dword:00000001
Solution 3:
The only way I have found to change this is directly on the code :
at the very beginning of your app you set
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
you should include the system.net
class
I did this before calling a web service because we had to block tls1 too.