【发布时间】:2011-11-03 10:31:18
【问题描述】:
我正在消费一些服务并且消费的服务提供者已经给出了证书。
所以我已经在 LocalMachine 上安装了证书,并通过以下代码将证书与我发布的 Web 请求附加在一起,以便从 Web 服务获得响应。
X509Certificate cert = null;
string ResponseXml = string.Empty;
// Represents an X.509 store, which is a physical store
// where certificates are persisted and managed
X509Store certStore = new X509Store(StoreName.My, StoreLocation.LocalMachine);
certStore.Open(OpenFlags.ReadOnly);
X509Certificate2Collection results =
certStore.Certificates.Find(X509FindType.FindBySubjectDistinguishedName,
Constants.CertificateName, false);
certStore.Close();
if (results != null && results.Count > 0)
cert = results[0];
else
{
ErrorMessage = "Certificate not found";
return ErrorMessage;
}
webClient.TransportSettings.ClientCertificates.Add(cert);
当我使用 ASP.net Cassini(ASP.NET 开发服务器)运行代码时,这非常有效。
但是当我在 IIS 7.0 中托管此代码时,它会给出 forbidden 403 Error 作为响应。
请提出建议。
【问题讨论】:
标签: asp.net security iis-7 ssl ssl-certificate