c# - .NET Framework 3.5 和 TLS 1.2

标签 c# asp.net

我目前有一个使用 .NET 3.5 框架的 Web 应用程序,我想知道它是否与 TLS 1.2 兼容。在我们的代码中,我们没有指定 TLS 版本。这是一个遗留应用程序,现在不考虑重新编译。我没有找到太多关于你是否可以的信息,但我的印象是兼容性更依赖于操作系统版本。看起来最低是 2008 R2。目标是让 Paypal 在 7 月 1 日之前正常通信。

最佳答案

如前所述,.net 3.5.1 现在支持 TLS 1.2;但您不需要@Paulina 的回答中提到的注册表更改。

我正在使用 VS 2008 和 .net 3.5.30729.4926。我所要做的就是:

添加导入:

Imports System.Security.Authentication
Imports System.Net

将此添加到我的代码 (C#) 中:

public const SslProtocols _Tls12 = (SslProtocols)0x00000C00;
public const SecurityProtocolType Tls12 = (SecurityProtocolType)_Tls12;
ServicePointManager.SecurityProtocol = Tls12

VB.net 版本:

Const _Tls12 As SslProtocols = DirectCast(&HC00, SslProtocols)
Const Tls12 As SecurityProtocolType = DirectCast(_Tls12, SecurityProtocolType)
ServicePointManager.SecurityProtocol = Tls12

选自:https://support.microsoft.com/en-us/help/3154518/support-for-tls-system-default-versions-included-in-the-.net-framework注意:通过在我的代码中定义常量,我可以忽略文章中的所有其他内容,包括注册表编辑和 cs 文件。

关于c# - .NET Framework 3.5 和 TLS 1.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43240611/

相关文章:

c# - Find() 和 First() 抛出异常,如何返回 null?

c# - Xamarin iOS ViewCellRenderer

c# - Azure Function v1 禁止访问云中的存储队列

asp.net - 404页面response.redirect与server.transfer

c# - 在 asp.net 中标准化 jpeg 大小

ASP.NET:Ro​​slyn 页面更改速度缓慢

c# - 如何更改文本框中乌尔都语字符的字体系列

c# - 如何获取我在SQL中输入的值

c# - MVC 4 强类型 View 不传递 Controller 模型

javascript - 如何处理 ASP .NET Api HTTPResponseMessage 来下载文件