【发布时间】:2017-04-22 04:16:54
【问题描述】:
我需要从我的 Azure Function 访问证书。
我按照Runtime error loading certificate in Azure Functions 中概述的步骤进行操作,但没有成功。
private static X509Certificate2 GetCertificate(string thumbprint, TraceWriter log)
{
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
try
{
store.Open(OpenFlags.ReadOnly);
log.Info("Enumerating certificates");
foreach (var cert in store.Certificates) {
log.Info(cert.Subject);
}
var col = store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false);
if (col == null || col.Count == 0)
{
return null;
}
return col[0];
}
finally
{
store.Close();
}
}
上传到 Azure 函数的两个证书和设置 WEBSITE_LOAD_CERTIFICATES 也被添加并设置为 * 或所需证书的 thumpbrint,但无济于事。
GetCertificate 方法应该打印存储区中所有证书的列表,但存储区是空的。
关于如何解决这个问题的任何线索?
【问题讨论】:
-
您是否尝试为网络作业搜索类似问题?因为解决方案是相同的
-
是的。他们都建议上面链接中概述的方法应该有效。但事实并非如此。
-
当我在 azure 中访问证书时,我总是使用 StoreLocation.LocalMachine。我没有在 Functions 中尝试过,但在其他 WebApps 和 CloudService 中它可以与 LocalMachine 一起使用
-
LocalMachine 确实有一些证书,但不是我通过 Azure 门户上传的证书。
-
Okey... 我试过了,也遇到了同样的问题。然后再试一次,但这次我创建了选择应用服务计划而不是托管计划的功能......并且还确保当我将指纹复制粘贴到设置时,我检查了没有添加额外的不可打印字符并且我得到了你的代码正常工作!!!尝试按照步骤操作,如果成功,请告诉我!
标签: c# azure ssl azure-functions