Accessing Certificate from within a C# Azure function(从 C# Azure 函数中访问证书)
问题描述
我需要从我的 Azure Function 访问证书.
I need to access a certificate from my Azure Function.
我按照 运行时错误加载证书Azure Functions 但没有成功.
I followed the steps outlined in Runtime error loading certificate in Azure Functions but it didn't work out.
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,但无济于事.
Two certificates where uploaded to the Azure Function and the setting WEBSITE_LOAD_CERTIFICATES was added as well and set to either * or to the thumpbrint of the required certificate, but to no avail.
GetCertificate 方法应该打印存储区中所有证书的列表,但存储区是空的.
The GetCertificate method should print a list of all certificates in the store, but the store is empty.
关于如何解决这个问题的任何线索?
Any clues on how to solve this?
推荐答案
更新:消费计划现在支持客户端证书.
UPDATE: Client certificates are now supported in the Consumption plan.
我们的消费计划尚不支持客户端证书,仅在应用服务计划中支持.我们的 repo here 中的一个问题对此进行了跟踪.我们正在努力解决这个问题 - 请关注该问题的状态.谢谢.
Client certificates are not yet supported in our Consumption plan, only in App Service plan. This is tracked by an issue in our repo here. We're working on it - please follow that issue for status. Thanks.
这篇关于从 C# Azure 函数中访问证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 C# Azure 函数中访问证书
基础教程推荐
- rabbitmq 的 REST API 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- MS Visual Studio .NET 的替代品 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01