【问题标题】:Forbidden 403 error when attaching client certificate附加客户端证书时出现禁止的 403 错误
【发布时间】: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


    【解决方案1】:

    你应该试试这个:

    winhttpcertcfg -g -c LOCAL_MACHINE\MY -s (MyCertificate) -a ASPNET

    事实证明,安装证书的用户自动 授予对私钥的访问权限,我想在您的情况下就是您,因此它可以在开发环境中使用。当 Web 前端出现时,您不再是用户,而是 ASPNET。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-16
      • 1970-01-01
      相关资源
      最近更新 更多