从 C# Azure 函数中访问证书
Accessing Certificate from within a C# Azure function
我需要从我的 Azure 函数访问证书。
我按照 中概述的步骤进行操作,但没有成功。
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,但无济于事。
GetCertificate 方法应该打印商店中所有证书的列表,但商店是空的。
关于如何解决这个问题的任何线索?
更新:
Consumption 计划现在支持客户端证书。
我们的 Consumption 计划尚不支持客户端证书,仅在 App Service 计划中支持。这是由我们的回购 here 中的一个问题跟踪的。我们正在努力 - 请关注该问题的状态。谢谢
我需要从我的 Azure 函数访问证书。
我按照
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,但无济于事。
GetCertificate 方法应该打印商店中所有证书的列表,但商店是空的。
关于如何解决这个问题的任何线索?
更新: Consumption 计划现在支持客户端证书。
我们的 Consumption 计划尚不支持客户端证书,仅在 App Service 计划中支持。这是由我们的回购 here 中的一个问题跟踪的。我们正在努力 - 请关注该问题的状态。谢谢