azure - How to manage signed certificates with Azure Function V2
问题描述
I am working on Azure Functions App on Consumption Plan. The Func App required to load a specific signed certificate.
In local machine I setup the certificate as personal certificate and everything works fine.
After publishing on azure, I am getting this error:
There are 0 certificates with the subject name cert.name in LocalMachine, MyUse scripts/certificates/ to generate this
Nothing helpful on SO or even in Azure Func documentation on how to use certificate with azure functions.
Anyone has experience with that?
解决方案
我明白了,这很简单。
首先转到您的 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();
...
推荐阅读
- latex - 一个 \cite 弄乱了我的其他引文
- google-sheets - Google 电子表格 - 从第二列返回最接近的值
- webpack - HtmlWebpackPlugin 将 bundle.[hash].js/css 加载到基本树枝文件中
- amazon-web-services - Fargate:我可以重启特定的容器吗?
- pandas - Pandas - 将浮点类型的列转换为日期时间
- r - 是否有一个 R 函数用于在不使用循环的情况下根据另一列的修改版本重新编码列?
- android - 使用 GPS 进行车辆跟踪的 Android 应用程序
- pip - pypdf2 和 PyPDF2 一样吗?
- javascript - ng.probe(selector) 总是导致 NULL
- r - r locf 多列和分组依据