I have a .NET 4.8 application which is a small Excel Add-in (thus running in Office/Excel) which performs HTTP (REST) requests and shows the data in Excel.
On the webserver we reconfigured to only allow TLS 1.2 and suddenly the HTTP Requests do not work anymore with this WebException:
The underlying connection was closed: An unexpected error occurred on a send.
Test-client OSes are Windows 10 and 8 (fully patched). Thus supporting TLS 1.2 according to https://docs.microsoft.com/en-us/dotnet/framework/network-programming/tls : "Supported, and enabled by default."
Executing the following in PowerShell gives:
[Net.ServicePointManager]::SecurityProtocol
SystemDefault
The following registry keys - which are often mentioned in documentation and blogs - are NOT set (they do not exist - also not the WOW6432Node variants):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SystemDefaultTlsVersions
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SchUseStrongCrypto
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp\DefaultSecureProtocols
Setting HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SchUseStrongCrypto=1
"fixes" the problem.
I can also manually enable TLS 1.2 and the problem goes away, but that removes control from the OS back to the application, which does not seem to be the underlying idea of .NET 4.8:
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;
My questions:
- How can I find out what
SystemDefault
evaluates to in .NET. How can I find this? - Why does TLS 1.2 not seem to enabled without setting registry keys?
- My assumption is that TLS 1.2 should be supported with .NET 4.8 without any system modifications (like registry keys) and without any code changes. Is this assumption wrong?
Addition I found these Github .net issues which seem to describe what I experience:
GitHub: Not getting default values on .NET 4.7.2 on Windows 10 (1709)
Unfortunately I have no machines old enough to not have the KB update yet. I may not be asking at the right place here, but is it possible that .NET 4.8 requires registry keys to get proper TLS 1.2 working?
SchUseStrongCrypto = 1
in the Registry, then you're not using .Net 4.8: that .Net version has automatic opt-in for this (the Registry key is useless). You can only opt-out. Check your build and the dependencies / libraries / whatever that query HTTPS resources. – Jimi