.NET Framework 版本 3.5 及更早版本不支持应用程序使用传输层安全性 (TLS) 系统默认版本作为加密协议。 此更新使 TLS v1.2 可以在 .NET Framework 3.5 中使用。
注意 此内容已在更新Windows提供。 若要获取内容,请扫描Windows更新以获取最新的.NET Framework更新。 如果系统通过 Windows 更新完全更新,则无需进一步操作。
解决方法
下载信息
与 KB3154519 对应的修补程序已取代 .NET Framework 的最新更新,其中包含 KB3154519 中以前包含的所有修补程序。 建议安装最新更新的 .NET Framework。 我们在此方面进行了以下改进:
-
可以将以下注册表项设置为使用 SSL 和 TLS 的操作系统默认值,而不是在计算机上运行的托管应用程序的硬编码 .NET Framework 默认值。
-
对于 64 位操作系统:[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727]
"SystemDefaultTlsVersions"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727] "SystemDefaultTlsVersions"=dword:00000001 -
对于 32 位操作系统:[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727]
"SystemDefaultTlsVersions"=dword:00000001
注意 如果应用程序已在代码中或通过配置文件将 ServicePointManager.SecureProtocol 设置为特定值,或使用 SslStream.AuthenticateAs* API 指定特定的 SslProtocols 枚举,则不会发生注册表设置行为。
-
-
此外,我们添加了 SslProtocolsExtensions 枚举,可用于设置 TLS v1.2、TLS v1.1,以及面向 .NET Framework 版本 2.0 SP2 时 ServicePointManager.SecurityProtocol 属性的操作系统默认值。 (请参阅开发人员指南部分,了解如何使用 extensions.)
请注意Windows Vista SP2 和 Windows Server 2008 SP2 不支持传输层安全性 (TLS) 1.0 版协议版本。 在 Windows Vista SP2 或 Windows Server 2008 SP2 上运行的托管 .NET Framework 2.0 SP2 应用程序不能使用 TLS 1.2 或 TLS 1.1,即使这些协议在 ServicePointManager.SecurityProtocol 属性中设置。
有关如何下载 Microsoft 支持文件的更多信息,请单击以下文章编号,以查看 Microsoft 知识库中相应的文章:
119591 如何从联机服务获取 Microsoft 支持文件 Microsoft 扫描了此文件中的病毒。 Microsoft 使用的是文件发布时可以获得的最新病毒检测软件。 该文件存储在安全性得到增强的服务器上,以防止对文件进行未经授权的更改。
开发人员指南
新扩展的定义在下列文件中:
-
SecurityProtocolTypeExtensions.csnamespace System.Net
{ 使用 System.Security.Authentication; 公共静态类 SecurityProtocolTypeExtensions { public const SecurityProtocolType Tls12 = (SecurityProtocolType) SslProtocolsExtensions.Tls12; public const SecurityProtocolType Tls11 = (SecurityProtocolType) SslProtocolsExtensions.Tls11; public const SecurityProtocolType SystemDefault = (SecurityProtocolType) 0; } } -
SslProtocolsExtensions.csnamespace System.Security.Authentication
{ 公共静态类 SslProtocolsExtensions { public const SslProtocols Tls12 = (SslProtocols) 0x00000C00; public const SslProtocols Tls11 = (SslProtocols) 0x00000300; } }
若要包括对 TLS v1.2 的支持,请包含项目中的源文件,然后使用下列方法设置协议版本:
-
使用基于 ServicePointManager 的 API 的应用程序可以使用以下方法设置协议:
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolTypeExtensions.Tls12; -
使用 SslStream AuthenticateAsClient (String、X509CertificateCollection、SslProtocols、布尔) 重载的应用程序可以将 SslProtocols 值设置为 SslProtocolsExtensions.Tls12。
如果设置了第一个段落中提到的注册表设置,并且应用程序中的 SslProtocols 值设置为 SslProtocols.None,则选择的系统默认行为将取决于 Windows 版本。
此外,更改应用程序代码以启用对 .NET Framework 3.5 SP1 的 TLS v1.2 支持时,应确保在未部署此修补程序的计算机上解决以下异常:-
如果未安装修补程序,应用程序调用 ServicePointManager.SecurityProtocol 设置新值时,基于 ServicePointManager 的 API (HTTP、FTP、SMTP) 将引发"System.NotSupportedException: 不支持请求的安全协议"。
-
如果未安装修补程序,则基于 SslStream 的 API 在调用其中一个 AuthenticateAs* API 时会引发异常:
System.ArgumentException:指定的值无效"SslProtocolType"枚举中指定。
参数名称:sslProtocolType
注意 仅适用于 SslStream,Tls12、Tls11 与任何现有的 Tls、Ssl3、Ssl2 (组合,例如 Tls12 |Tls11 |Tls) 会以无提示方式降级到现有协议 (例如:Tls) 没有修补程序的系统中。 它将连接到 Tls,而不会引发异常。
更多信息
若要启用 TLS v1.1 或 v1.2 作为操作系统默认值,请按照 https://technet.microsoft.com/en-us/library/dn786418 (v=ws.11) .aspx#BKMK_SchannelTR_TLS12 中的说明进行操作。 请注意,TLS v1.1 和 v1.Windows 2 在 Vista 或 Windows Server 2008 中不可用。 如果必须禁用由特定应用程序的"解析"部分中提到的注册表项设置的操作系统默认值,可以通过为文件 .exe>> DWORD 0 添加以下注册表项HKEY_LOCAL_MACHINE\SOFTWARE\[Wow6432Node\]Microsoft\.NETFramework\v2.0.50727\System.Net.ServicePointManager.SystemDefaultTlsVersions <<完整路径来这样做 C:\MyApp\MyApp.exe DWORD 0
有关 TLS v1.2 详细信息,请参阅 TLS v1.2 介绍。 启用 SystemDefaultTlsVersions .NET 注册表项后,每个版本的 Windows 将发生不同的行为,如下表所示。
Windows 版本 |
SSL2 客户端 |
SSL2 服务器 |
SSL3 客户端 |
SSL3 服务器 |
TLS 1.0 客户端 |
TLS 1.0 服务器 |
TLS 1.1 客户端 |
TLS 1.1 服务器 |
TLS 1.2 客户端 |
TLS 1.2 服务器 |
---|---|---|---|---|---|---|---|---|---|---|
Windows Vista SP2 和 Windows Server 2008 SP2 |
关闭 |
打开 |
打开 |
打开 |
打开 |
打开 |
不适用 |
不适用 |
不适用 |
不适用 |
Windows 7 SP1 和 Windows Server 2008 R2 SP1 |
关闭 |
打开 |
打开 |
打开 |
打开 |
打开 |
关闭 |
关闭 |
关闭 |
关闭 |
Windows Server 2012 |
关闭 |
关闭 |
打开 |
打开 |
打开 |
打开 |
打开 |
打开 |
打开 |
打开 |
Windows 8.1 和 Windows Server 2012 R2 |
关闭 |
关闭 |
打开 |
打开 |
打开 |
打开 |
打开 |
打开 |
打开 |
打开 |
Windows 10 |
关闭 |
关闭 |
打开 |
打开 |
打开 |
打开 |
打开 |
打开 |
打开 |
打开 |
Windows 10 (1511) |
关闭 |
关闭 |
打开 |
打开 |
打开 |
打开 |
打开 |
打开 |
打开 |
打开 |
Windows 10 (1607) 和 Windows Server 2016 |
不适用 |
不适用 |
关闭 |
关闭 |
打开 |
打开 |
打开 |
打开 |
打开 |
打开 |