I need to use TLS 1.2 to connect from my .NET web service to another that is going to force TLS 1.2. I found a resource that said .NET 4.6 uses TLS 1.2 by default so that sounded like the easiest solution. I updated the .NET framework on the server and restarted. In IIS I tried to make an application pool using .NET 4.6 but 4.0 was the only option. Then I found something that said it would still say 4.0 because 4.6 is an "in place" update to .NET 4.0. So I thought maybe I was done. However on an error page that I got for unrelated reasons, it said Microsoft .NET Framework Version:4.0.30319
so it seems I have not successfully upgraded. Any pointers on how to make sure my application pool is using .NET 4.6, or more generally how to enable TLS 1.2?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
We actually just upgraded a .NET web service to 4.6 to allow TLS 1.2.
What Artem is saying were the first steps we've done. We recompiled the framework of the web service to 4.6 and we tried change the registry key to enable TLS 1.2, although this didn't work: the connection was still in TLS 1.0. Also, we didn't want to disallow SLL 3.0, TLS 1.0 or TLS 1.1 on the machine: other web services could be using this; we rolledback our changes on the registry.
We actually changed the Web.Config files to tell IIS: "hey, run me in 4.6 please".
Here's the changes we added in the web.config + recompilation in .NET 4.6:
And the connection changed to TLS 1.2, because IIS is now running the web service in 4.6 (told explicitely) and 4.6 is using TLS 1.2 by default.
if you're using .Net earlier than 4.5 you wont have Tls12 in the enum so state is explicitly mentioned here
For me below worked:
Step 1: Downloaded and installed the web Installer exe from https://www.microsoft.com/en-us/download/details.aspx?id=48137 on the application server. Rebooted the application server after installation was completed.
Step 2: Added below changes in the web.config
Step 3: After completing step 1 and 2, it gave an error, "WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive)" and to resolve this error, I added below key in appsettings in my web.config file
Three steps needed:
Explicitly mark SSL2.0, TLS1.0, TLS1.1 as forbidden on your server machine, by adding
Enabled=0
andDisabledByDefault=1
to your registry (the full path isHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols
). See screen for detailsExplicitly enable
TLS1.2
by following the steps from 1. Just useEnabled=1
andDisabledByDefault=0
respectively.NOTE: verify server version:
Windows Server 2003
does not support theTLS 1.2
protocolEnable
TLS1.2
only on app level, like @John Wu suggested above.System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
Hope this guide helps.
UPDATE As @Subbu mentioned: Official guide
Add the following code before you instantiate your web service client:
Or for backward compatibility: