[英]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.