【发布时间】: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