簡體   English   中英

Dynamics CRM:強制 TLS 1.2 后 WCF 安全錯誤

[英]Dynamics CRM: WCF Security Error after forcing TLS 1.2

我們有一個功能性 WCF 連接到我們的 Dynamics CRM(2016 內部部署)。 我們最近需要在 Dynamics 服務器上刪除 SSL 2.0/3.0 和 TLS 1.0/1.1 以滿足合規性(強制 TLS 1.2)。 這破壞了我們的 WCF 連接。 我們會看到以下錯誤:

System.InvalidOperationException:元數據包含無法解析的引用:“ https://DynamicsURL.com/OrgName/XRMServices/2011/Organization.svc?wsdl ”。 ---> System.Net.WebException:底層連接已關閉:發送時發生意外錯誤。 ---> System.IO.IOException:無法從傳輸連接讀取數據:現有連接被遠程主機強行關閉。 ---> System.Net.Sockets.SocketException: 現有連接被遠程主機強行關閉

我沒有配置這個並且我沒有代碼導出,但據我所知,連接安全性都在 web.config 中,需要調整。 它看起來像這樣:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IWCFService" sendTimeout="00:25:00" maxReceivedMessageSize="1000000">
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://DynamicsURL.com:8080/WCF/wcfservice.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFWCFService" contract="WCF.IWCFService" name="BasicHttpBinding_IWCFService" />
    </client>
  </system.serviceModel

該問題在實施以下更改后開始:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\Multi-Protocol Unified Hello\Client]
"Enabled"=dword:00000000
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\Multi-Protocol Unified Hello\Server]
"Enabled"=dword:00000000
"DisabledByDefault"=dword:00000001

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

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

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

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0]

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

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

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0]

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

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Server]
"Enabled"=dword:00000000
"DisabledByDefault"=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:00000000
"DisabledByDefault"=dword:00000001

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

[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

更新

我在調用 WCF 應用程序的客戶端應用程序的 web.config 中嘗試了以下 system.serviceModel 配置,但我收到以下錯誤:

通信 object,System.ServiceModel.Channels.ServiceChannel,不能用於通信,因為它在故障 state 中。

 <system.serviceModel> <bindings> <wsHttpBinding> <binding name="BasicHttpBinding_IWCFService"> <security mode="Transport"> <transport clientCredentialType="Basic" /> </security> </binding> </wsHttpBinding> </bindings> <client> <endpoint address="https://DynamicsURL.com:8080/WCF/WCFService.svc" binding="wsHttpBinding" bindingConfiguration="BasicHttpBinding_IWCFService" contract="WCF.IWCFService" name="BasicHttpBinding_IWCFService" /> </client> </system.serviceModel>

更新 3

如下所述,我通過添加下面顯示的 Reg 值解決了這個問題。 但是,我現在面臨其他問題。 我正在使用SSLLabs掃描我的網站,我得到了 B。解決方案是啟用並更喜歡TLS_DHE_RSA_WITH_AES_256_GCM_SHA384TLS_DHE_RSA_WITH_AES_128_GCM_SHA256芯片。 這樣做,導致 SSLLabs 抱怨 DH,所以我將其設置為 2048。現在看起來一切都很好,但我遇到了Schannel錯誤(如下)。我發現了一些啟用使用 FIPS安全設置的建議,但是當我這樣做時,它破壞了我在該機器上運行的許多功能(Dynamics CRM 插件)。 例如,插件會因以下錯誤而失敗: Error Occurred in Plugin NameRemoved exception: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms. 其他建議是刪除TLS_DHE_RSA_WITH_AES_256_GCM_SHA384TLS_DHE_RSA_WITH_AES_128_GCM_SHA256芯片,但我無法將其刪除以進行分級。 現在,除了錯誤之外,一切似乎都正常運行。

錯誤

  • 已生成致命警報並將其發送到遠程端點。 這可能會導致連接終止。 TLS 協議定義的致命錯誤代碼為 20。 Windows SChannel 錯誤 state 為 960。

  • 創建 SSL 客戶端憑據時發生致命錯誤。 內部錯誤 state 為 10013。

 Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727] "SystemDefaultTlsVersions"=dword:00000001 "SchUseStrongCrypto"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319] "SystemDefaultTlsVersions"=dword:00000001 "SchUseStrongCrypto"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727] "SystemDefaultTlsVersions"=dword:00000001 "SchUseStrongCrypto"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319] "SystemDefaultTlsVersions"=dword:00000001 "SchUseStrongCrypto"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.5.1] "SystemDefaultTlsVersions"=dword:00000001 "SchUseStrongCrypto"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.5.23026] "SystemDefaultTlsVersions"=dword:00000001 "SchUseStrongCrypto"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319] "SystemDefaultTlsVersions"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319] "SystemDefaultTlsVersions"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727] "SystemDefaultTlsVersions"=dword:00000001

根據 Microsoft 文檔: Transport Layer Security (TLS) best practice with the .NET Framework

對於 WCF 使用 .NET 框架 3.5 - 4.5.2 使用 TCP 傳輸安全證書憑證

WCF 框架的這些版本被硬編碼為使用值 SSL 3.0 和 TLS 1.0。 這些值不能更改。 您必須更新並重新定位到 NET Framework 4.6 或更高版本才能使用 TLS 1.1 和 1.2。

看起來您可能需要將 WCF 服務升級到 .NET 框架到 4.6.2 或更高版本。

首先,您的客戶端連接沒有正確配置 Https 服務地址。

<binding name="BasicHttpBinding_IWCFService" 

bindingConfiguration="BasicHttpBinding_IFWCFService"

此外,基於 TLS 最佳實踐與 Dotnet 框架。
https://docs.microsoft.com/en-us/dotnet/framework/network-programming/tls
我們不應該干預底層 TLS 版本的決定。

不要指定 TLS 版本。 配置您的代碼以讓操作系統決定 TLS 版本。

根據您的描述,為了在 HTTPS 上實現 TLS1.2 通信,我們應該先將 Dotnetframework SDK 版本升級到上述 4.6.1,然后再在服務器端配置 Z0E8433F9A404F1F3BA16ZC 服務端點。
然后在客戶端,我們也安裝上面的Dotnetframework4.6。 並在調用服務器之前使用以下代碼指定 TLS 版本。

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

我們可以使用 Wireshark 檢查實用的 TLS 版本。 在此處輸入圖像描述
如果有什么我可以幫忙的,請隨時告訴我。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM