在.NET Framework 4.0中使用TLS 1.2的问题 [英] Issue to use TLS 1.2 in .NET Framework 4.0
问题描述
我禁用了TLS 1.0。因此,我们尝试在使用.Net Framework 4.0的.Net应用程序中使用TLS 1.2。
I got TLS 1.0 disabled. So we are trying to use TLS 1.2 in our .Net application which is using .Net Framework 4.0.
我已经在开始时添加了此代码
I have added the code for this at the start
System.Net.ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
它在我的本地系统上运行良好。
It works perfectly on my local system.
但是我不确定为什么在服务器(Windows Server 2008 R2)上部署代码时它不起作用。我检查了一切。 .Net框架存在于服务器上。但是,它仍然只在服务器上产生相同的问题。
But i am not sure why its not working when I deploy the code on server (Windows Server 2008 R2). I checked everything. .Net framework is present on server. But still its giving the same issue on server only.
在这里我缺少什么吗?
推荐答案
根据此帖子:
.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 (noTls12
member here)SecurityProtocolType
enum for current .Net
这篇关于在.NET Framework 4.0中使用TLS 1.2的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!