【发布时间】:2017-06-21 09:37:55
【问题描述】:
我在 Azure 中有一个 B1 应用服务,我已经在其中安装了我的证书,如下所示:
当我尝试获取证书时,它找不到它。好像没有安装证书一样。这是我的代码:
using (X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser))
{
certStore.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certCollection = certStore.Certificates.Find(
X509FindType.FindByThumbprint,
certificateThumbprint,
false);
if (certCollection.Count > 0)
{
return certCollection[0];
}
throw new Exception("Certificate not found!");
}
我已经验证了证书指纹,甚至尝试将其硬编码为字符串。
当我尝试像这样打印商店中的证书数量时:
Console.WriteLine("certStore.Certificates.Count : " + certStore.Certificates.Count);
它返回零个证书。
我还尝试更改 StoreName 和 StoreLocation - 结果仍然相同。即使没有提供任何StoreName 或StoreLocation,它仍然找不到任何证书。
【问题讨论】:
标签: azure ssl azure-web-app-service