禁用 TLS 1.0 会中断 ASP.NET 个应用程序

Disabling TLS 1.0 breaks ASP.NET application

运行 Windows 服务器 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

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

A fatal alert was generated and sent to the remote endpoint. This may result in termination of the connection. The TLS protocol defined fatal error code is 70. The Windows SChannel error state is 105.

如果我只为 TLS 1.0 恢复注册表设置(启用,而不是 DisabledByDefault),一切都恢复正常。

在system.web中使用:

<httpRuntime targetFramework="4.7.2" />

我错过了什么?

您是否尝试启用 schannel 日志记录以获取更多信息?

https://support.microsoft.com/en-us/help/260729/how-to-enable-schannel-event-logging-in-iis

希望能揭开缺失的部分。

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

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

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

您的站点可能正在通过不支持 TLS 1.1+ 的 SSL 与某些内容进行通信。您可以允许站点扫描器看不到的传出 TLS 1.0 连接,但这些连接的安全性较低。

如果您使用的是 .net 4.7 或更高版本,请试试这个。

我为此使用了IIS Crypto。您禁用 TLS 1.0 和 1.1,应用并重新启动。在此之后,您的所有应用程序、SharePoint 和网站都将使用 TLS 1.2

您还应该在 web.config 文件中指明目标版本

<system.web>
   <httpRuntime targetFramework = "4.7.2" />
   <compilation targetFramework = "4.7.2"> </compilation>
</system.web>

这将使其支持 TLS 1.2 并始终强制执行此协议。