TLS1.1 and TLS1.0 (and lower) protocols are insecure and should no longer be used.
For .NET 4.7 or later, you do not need to set System.Net.ServicePointManager.SecurityProtocol
. The default value (SecurityProtocolType.SystemDefault
) allows the operating system to use whatever versions it has been configured for, including any new versions that may not have existed at the time your application was created.
If you want to explicitly code this in .NET, rather than specify the allowed protocols, disable the disallowed protocols before making any connections:
// TLS must be 1.2 or greater. Disable SSL3, TLS1.0 and TLS1.1 [Note: this is the default behaviour for .NET 4.7 or later]
ServicePointManager.SecurityProtocol &= (~SecurityProtocolType.Ssl3 & ~SecurityProtocolType.Tls & ~SecurityProtocolType.Tls11);