我正在使用消费计划上的 Azure Functions 应用程序。 Func 应用程序需要加载特定的签名证书。
在本地计算机中,我将证书设置为个人证书,一切正常。
在 azure 上发布后,我收到此错误:
There are 0 certificates with the subject name cert.name in LocalMachine, MyUse scripts/certificates/ to generate this
关于如何将证书与 azure 函数一起使用,SO 甚至 Azure Func 文档都没有任何帮助。
有人有这方面的经验吗?
最佳答案
我明白了,而且非常简单。
首先转到 Function App 下的平台功能,您应该会找到 SSL,如下所示。
然后您可以根据需要添加公共(public)、私有(private)或 SSL 证书。就我而言,我想添加一个我已经导出的私有(private)证书并拥有它的私钥。
上传证书后,转到应用设置并添加此键/值:
WEBSITE_LOAD_CERTIFICATES: "Your Cert Thumbprint"
您应该能够使用此指纹加载证书,如下所示:
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();
...
关于azure - 如何使用 Azure Function V2 管理签名证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53778977/