【问题标题】:How to manage signed certificates with Azure Function V2如何使用 Azure Function V2 管理签名证书
【发布时间】:2019-05-15 16:19:51
【问题描述】:
我正在开发 Azure Functions App on Consumption Plan。加载特定签名证书所需的 Func 应用程序。
在本地机器中,我将证书设置为个人证书,一切正常。
在 azure 上发布后,我收到此错误:
LocalMachine 中有 0 个主题名称为 cert.name 的证书,MyUse scripts/certificates/ 来生成这个
在 SO 甚至 Azure Func 文档中都没有关于如何将证书与 azure 函数一起使用的帮助。
有人有这方面的经验吗?
【问题讨论】:
标签:
azure
ssl
certificate
azure-functions
【解决方案1】:
我明白了,而且很简单。
首先进入你的Function App下的平台特性,你应该会找到如下图所示的SSL。
然后您可以根据需要添加公共、私有或 SSL 证书。在我的情况下,我想添加一个我已经导出并拥有它的私钥的私有证书。
上传您的证书后,转到您的应用设置并添加此键/值:
WEBSITE_LOAD_CERTIFICATES:“您的证书指纹”
您应该能够像这样使用此指纹加载证书:
using System;
using System.Security.Cryptography.X509Certificates;
...
X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
certStore.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certCollection = certStore.Certificates.Find(
X509FindType.FindByThumbprint,
// Replace below with your certificate's thumbprint
"000000000000000000000000000000000000000",
false);
// Get the first cert with the thumbprint
if (certCollection.Count > 0)
{
X509Certificate2 cert = certCollection[0];
// Use certificate
Console.WriteLine(cert.FriendlyName);
}
certStore.Close();
...