在.NET Framework 4.0中使用TLS 1.2的问题 [英] Issue to use TLS 1.2 in .NET Framework 4.0

查看:660
本文介绍了在.NET Framework 4.0中使用TLS 1.2的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我禁用了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 to TLS 1.0 while .NET 4.5 supports up to TLS 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文章:

  • SecurityProtocolType enum for .Net 4.0 (no Tls12 member here)
  • SecurityProtocolType enum for current .Net

这篇关于在.NET Framework 4.0中使用TLS 1.2的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆