簡體   English   中英

.NET中的客戶端證書身份驗證(Windows Server)

[英]Client Certificate Authentication in .NET (Windows Server)

我已部署的Web應用程序存在一個非常奇怪的問題。

相關數據:

Application Server: IIS 7.5
Server: Windows Server 2008 R2 Standard SP1
Framework: ASP.NET
.NET Framework: 4 (4.0.30319)
Application Pool: Integrated

在Web應用程序中,我使用了通過客戶端證書身份驗證進行身份驗證的服務。 我沒有與身份驗證本身有關的問題(它正在我的開發環境中工作)。 但是,每當我想使用服務器(生產)環境中的服務時,都會遇到問題。

這是CODE的相關部分:

private void SetupClienteCertificate(HttpWebRequest req)
{
        var binding = new BasicHttpBinding();
        binding.Security.Mode = BasicHttpSecurityMode.Transport;
        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
        var crt = new X509Certificate2(
            txtClientCertificateFile.Text, 
            txtCertificatePassword.Text, 
            X509KeyStorageFlags.MachineKeySet
        );
        req.ClientCertificates.Add(crt);
}

我遇到的錯誤很常見,很容易解釋:

The request was aborted: Could not create SSL/TLS secure channel.

它的最奇怪的部分是 ,如果我從C# .Net Windows Forms桌面應用程序(具有相同的.NET 4框架)運行完全相同的代碼 ,則可以獲取與服務器通信的代碼。

所以我的問題是: 為什么它不能在桌面應用程序中工作,而不能在ASP.NET Web應用程序中工作?

我已經確定的一些東西:

  1. 在注冊表中啟用了SSLv3,TLS,TLSv1,TLSv2
  2. 我忽略了SSL證書錯誤(不是必需的, 只是在情況下
  3. 每次更改明智的配置時,都要重新啟動應用程序池。

有任何想法嗎?

我想我能解決你的問題。 您可以確保運行應用程序池的帳戶具有足夠的特權來從證書存儲中讀取證書

暫無
暫無

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

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