zl程序教程

您现在的位置是:首页 >  后端

当前栏目

让.NET 4.0支持TLS1.2协议

Net协议 支持 4.0
2023-09-11 14:17:56 时间

The DEFAULT System.Net.ServicePointManager.SecurityProtocol in both .NET 4.0/4.5 is:

 SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls.

.NET 4.0 supports up to TLS 1.0 while .NET 4.5 supports up to TLS 1.2

However, an application targeting .NET 4.0 can still support up to TLS 1.2 if .NET 4.5 is installed in the same environment. .NET 4.5 installs on top of .NET 4.0, replacing System.dll.

I've verified this by observing the correct security protocol set in traffic with fiddler4 and by manually setting the enumerated values in a .NET 4.0 project:

ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 |(SecurityProtocolType)768 | (SecurityProtocolType)3072;