首页 > 解决方案 > 禁用 TLS 1.0 会破坏 ASP.NET 应用程序

问题描述

在 Windows Server 2012R2 上运行

我正在尝试在 IIS 上禁用 TLS 1.0,因为客户端有一个站点扫描程序,它突出显示这是一个安全问题。

我设置了一个干净的测试服务器,并且应用程序运行良好,直到我禁用 TLS 1.0。

我更新了所有适当的设置:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727]
"SchUseStrongCrypto"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727]
"SchUseStrongCrypto"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client]
"Enabled"=dword:00000000
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server]
"Enabled"=dword:00000000
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client]
"Enabled"=dword:ffffffff
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server]
"Enabled"=dword:ffffffff
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"Enabled"=dword:ffffffff
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"Enabled"=dword:ffffffff
"DisabledByDefault"=dword:00000000

在事件查看器中,我得到:

已生成致命警报并将其发送到远程端点。这可能会导致连接终止。TLS 协议定义的致命错误代码为 70。Windows SChannel 错误状态为 105。

如果我仅恢复 TLS 1.0 的注册表设置(启用,而不是 DisabledByDefault),一切都会再次正常。

在 system.web 中使用:

<httpRuntime targetFramework="4.7.2" />

我错过了什么?

标签: asp.netssliis-8windows-server-2012-r2

解决方案


应用程序本身必须更新以支持 TLS 1.2 握手,因此如果您只能访问配置,则不一定可以更改。如果底层代码不支持它,它将无法工作。

如果代码以 .NET 4.6 为目标,我相信 TLS 1.2 将在本地运行。在 4.5 中,必须放置一行代码,以便在任何网络发生之前执行它。编码:

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12

推荐阅读