簡體   English   中英

TLS致命:握手失敗

[英]TLS Fatal: Handshake Failure

我需要連接外部服務,並且客戶端身份驗證存在問題。 該服務需要證書,用戶名和密碼以及請求。

我正在使用Windows Server 2008 R2。

我已經收到帶有證書並已導入的PKCS#7軟件包:

  • SSL證書(僅具有公共密鑰)到LocalComputer / Personal
  • 中間CA和根CA到LocalComputer / TrustedRootCertificationAuthorities

我已經在Windows Register中啟用了TLS 1.0、1.1、1.2客戶端: Windows Register

我正在嘗試使用WCF客戶端和Web瀏覽器(IE和Chrome)連接到服務器。

WCF客戶端(.NET 4.6.1):

App.config:

<bindings>     
    <wsHttpBinding>
        <binding name="WSHttpBinding_ICalculator" >
            <security mode="Transport">
                <transport clientCredentialType="Certificate" />
            </security>
        </binding>
    </wsHttpBinding>
</bindings>
<behaviors>
    <endpointBehaviors>
        <behavior name="endpointCredentialBehavior">
            <clientCredentials>
                <clientCertificate findValue="<thumbprint>"
                           storeLocation="LocalMachine"
                           storeName="My"
                           x509FindType="FindByThumbprint" />
            </clientCredentials>
        </behavior>
    </endpointBehaviors>
</behaviors>

Program.cs:

ServicePointManager.Expect100Continue = true;

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
           | SecurityProtocolType.Tls11
           | SecurityProtocolType.Tls12;

using (var client = new ServiceClient())
{
    client.ClientCredentials.UserName.UserName = "username";
    client.ClientCredentials.UserName.Password = "pwd";

    client.Open();
    var response = client.DoSth();
}

我得到一個錯誤:

“無法使用權​​限...為SSL / TLS建立安全通道。”。

Internet Explorer顯示: IE錯誤

Chrome顯示以下信息: Chrome錯誤

我還嘗試通過Wireshark對其進行調試。 對我來說,懷疑來自客戶端的“證書”消息不包含任何證書(既不使用WCF客戶端也不使用Web瀏覽器)。 是否應在此處添加證書,如果是,可能是什么引起了問題?

Wireshark軟件包

我知道在stackoverflow和Google上有很多關於TLS和身份驗證的文章,但是我瀏覽了很多文章,卻沒有找到有關我做錯事情的任何信息。

我們最好不要指定TLS版本,而是配置代碼以讓操作系統決定。 通信中使用的特定TLS版本將由服務器和客戶端環境共同決定。
https://docs.microsoft.com/zh-cn/dotnet/framework/network-programming/tls
傳輸安全模式要求在通信之前建立服務器和客戶端之間的信任關系。
在我看來,該錯誤通常表示客戶端未正確安裝服務器證書。
https://docs.microsoft.com/zh-cn/dotnet/framework/wcf/feature-details/transport-security-with-certificate-authentication
只有服務器端添加Servicemetadata行為,我們才能訪問服務定義(WSDL)。
通常,客戶端提供足以證明其身份的證書,而無需再次提供用戶名/密碼。 就像生成的客戶端配置一樣,我們只需要提供一個證書即可。 如何具體調用服務,我們必須知道服務器或WSDL文件的配置。
請隨時告訴我是否有什么我可以幫助的。

暫無
暫無

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

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