'Issues making a TLS 1.2 request with .NET Framework 4.7+
We have a .NET 4.7+ application running on an Azure Cloud App Service. When we try to call and API that has TLS 1.2 minimum, using HttpWebRequest, we get a "The request was aborted: Could not create SSL/TLS secure channel" error. What I have read so far:
- Microsoft strongly advises against hard coding
ServicePointManager.SecurityProtocol, so I'm trying to avoid that solution unless it's absolutely necessary. Microsoft's guide - .NET 4.7+ should default to TLS 1.2 or use the OS configuration. On my Azure app, TLS 1.2 is set as the minimum Microsoft's guide
What can be causing my app to be using a lower TLS version? I have searched the code and could not find a manual TLS configuration anywhere. Is setting ServicePointManager.SecurityProtocol really my only solution?
Solution 1:[1]
Add This In your code:
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12
OR
If you have executable file simply update the associated configuration file, this file always named as [name of the executable].exe.config. If there's no such file, create one.
Once located or created, update its content to enable the compatibility switch required to support TLS 1.2:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<AppContextSwitchOverrides value="Switch.System.Net.DontEnableSystemDefaultTlsVersions=false"/>
</runtime>
</configuration>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | subeesh k |
