我正在使用消费计划上的Azure Functions应用程序。 Func App需要加载特定的签名证书。
在本地计算机上,我将证书设置为个人证书,并且一切正常。
在azure上发布后,出现此错误:
LocalMachine中有0个主题名称为cert.name的证书,可以使用MyUse脚本/ certificates /来生成
对于SO或什至在Azure Func文档中如何使用带天蓝色功能的证书都没有帮助。
有人有经验吗?
答案 0 :(得分:5)
我明白了,很简单。
首先转到功能应用程序下的平台功能,您应该找到如下所示的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();
...