【问题标题】:Cannot find the X.509 certificate using the following search criteria Only when publishing the API无法使用以下搜索条件找到 X.509 证书 仅在发布 API 时
【发布时间】:2018-12-12 06:26:39
【问题描述】:

我正在尝试使用需要证书的 web 服务

证书安装在本地计算机上,我的用户帐户安装在我的商店(个人)中。

在开发模式(visual studio)中,我使用以下代码链接证书:

string thumbprintVal = WebConfigurationManager.AppSettings["Thumbprint"];
                mPortType.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser,
                 StoreName.My, X509FindType.FindByThumbprint,
                thumbprintVal);

它在开发中运行良好。

但是当我将代码发布到 IIS 时,它会因给出以下错误而失败:

使用以下搜索条件找不到 X.509 证书: StoreName 'My',StoreLocation 'CurrentUser',FindType 'FindByThumbprint', FindValue '指纹值'。"}

有人可以帮忙吗?

【问题讨论】:

    标签: c# api certificate


    【解决方案1】:

    StoreLocation.CurrentUser 可能为运行 IIS 应用程序的用户指向不同的存储位置。当您在开发模式下运行应用程序时,它以you 运行,因此它可以访问您的认证存储位置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-03
      • 1970-01-01
      • 2012-10-26
      • 2010-10-10
      • 1970-01-01
      • 2011-10-25
      相关资源
      最近更新 更多