【问题标题】:Certificates List is empty in WebRoleWebRole 中的证书列表为空
【发布时间】:2013-08-29 19:00:26
【问题描述】:

我正在我的网络应用程序中编写代码,该代码需要列出和搜索安装在网络角色上的特定证书。 这是我的代码

// using System.Security.Cryptography.X509Certificates;

var store = new X509Store() ;
store.Open(OpenFlags.ReadOnly);
LoggingService.Info(String.Format(
     "{0} Certificate(s) are found in store",store.Certificates.Count));
for(int index=0;index<store.Certificates.Count;index++)
{
    LoggingService.Info(String.Format(
        "Subject:{0}, Thumbprint:{1}",store.Certificates[index].Subject,
        store.Certificates[index].Thumbprint));
}
_Certificate = store.Certificates.Find(
     X509FindType.FindByThumbprint, this.CertificateThumbprint, false)[0];

现在的问题是,即使通过门户在 Web 角色中添加了证书,并且还存在于配置文件中。 store.Certificates.Count 为零。此代码在模拟器中完美运行,但不知何故无法列出 Web 角色证书。如何访问安装在 Web 角色上的证书?

【问题讨论】:

  • 证书存储是否正确?任何错误(如权限问题)?
  • 是的证书存储是正确的。还登录了我的网络角色,奇怪的是个人存储中没有证书。但我可以在 IIS on web 角色中看到证书。

标签: azure azure-web-roles certificate-store


【解决方案1】:

知道了,我没有在 Store 类中提供任何商店名称和位置,并假设它会搜索每个商店和位置,但事实并非如此。然后我提供了商店名称和位置,现在系统能够找到证书。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-06
    • 2011-06-14
    • 2017-07-11
    • 1970-01-01
    • 2016-10-26
    • 1970-01-01
    相关资源
    最近更新 更多