Asp.net

禁用 TLS 1.0 會破壞 ASP.NET 應用程序

  • June 22, 2020

在 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" />

我錯過了什麼?

您的站點可能正在與不支持 TLS 1.1+ 的 SSL 通信。您可以允許站點掃描程序看不到的傳出 TLS 1.0 連接,但這些連接的安全性較低。

應用程序本身必須更新以支持 TLS 1.2 握手,因此如果您只能訪問配置,則不一定可以更改。如果底層程式碼不支持它,它將無法工作。

如果程式碼以 .NET 4.6 為目標,我相信 TLS 1.2 將在本地執行。在 4.5 中,必須放置一行程式碼,以便在任何網路發生之前執行它。編碼:

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

引用自:https://stackoverflow.com/questions/50338640