Azure应用服务:在X509Store中找不到证书(StoreName.My,StoreLocation.CurrentUser)

时间:2017-11-15 10:37:00

标签: c# azure ssl azure-web-app-service

我编写了一个程序,需要签名证书和其他一些东西。

我已将我的pfx文件作为私人证书上传到我的应用服务的SSL证书中。

enter image description here

然后我尝试在我的应用服务上看到已安装的证书,因为已经使用power shell描述了in here

enter image description here

但我现在的用户没有任何证书。

我也检查了我的本地机器,但它也没有。 enter image description here

我也不能使用我的c#代码找到它:

 X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
        certStore.Open(OpenFlags.ReadOnly);
        X509Certificate2Collection certCollection = certStore.Certificates.Find(X509FindType.FindByThumbprint, ThumbPrint, false);
        if (certCollection.Count == 0)
            throw new Exception("Certificate not found");

2 个答案:

答案 0 :(得分:6)

哦,我忘记在应用设置中添加值为*的WEBSITE_LOAD_CERTIFICATES:|

希望它可以帮助下一个人 enter image description here

答案 1 :(得分:2)

我们可以从blog获得答案。

  

添加名为 WEBSITE_LOAD_CERTIFICATES 的应用设置,并将其值设置为证书的指纹,这样您的网络应用就可以访问它了。

     

您可以多个逗号分隔指纹值可以将此值设置为“*”(不带引号),在这种情况下全部您的证书将加载到您的Web应用程序个人证书存储区。