更新时间:2023-02-11 16:36:30
根据此帖子:
.NET 4.0
最多支持TLS 1.0
,而.NET 4.5
最多支持TLS 1.2
.NET 4.0
supports up toTLS 1.0
while.NET 4.5
supports up toTLS 1.2
但是,面向应用程序 .NET 4.0
仍最多可以支持TLS 1.2。如果在同一环境中安装了.NET 4.5 。 .NET 4.5
安装在 .NET 4.0
之上,替换了 System.dll
。
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
.
因此,基本上,您需要将服务器升级到 .Net 4.5
启用 TLS 1.2
。
So basically you need to upgrade your server to .Net 4.5
to enable TLS 1.2
.
此外,您还可以简化代码并使代码更具可读性:
Also, you can simplify your code and make it more readable:
using System.Net;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
相关的MSDN文章:
.Net 4.0的SecurityProtocolType
枚举(此处没有 Tls12
成员) SecurityProtocolType
当前.Net的枚举 SecurityProtocolType
enum for .Net 4.0 (no Tls12
member here)SecurityProtocolType
enum for current .Net