[英]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應用程序中工作?
我已經確定的一些東西:
有任何想法嗎?
我想我能解決你的問題。 您可以確保運行應用程序池的帳戶具有足夠的特權來從證書存儲中讀取證書 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.