从 C# Azure 函数中访问证书

2

本文介绍了从 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 函数中访问证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

C# 中的多播委托奇怪行为?
Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)...
2023-11-11 C#/.NET开发问题
6

参数计数与调用不匹配?
Parameter count mismatch with Invoke?(参数计数与调用不匹配?)...
2023-11-11 C#/.NET开发问题
26

如何将代表存储在列表中
How to store delegates in a List(如何将代表存储在列表中)...
2023-11-11 C#/.NET开发问题
6

代表如何工作(在后台)?
How delegates work (in the background)?(代表如何工作(在后台)?)...
2023-11-11 C#/.NET开发问题
5

没有 EndInvoke 的 C# 异步调用?
C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)...
2023-11-11 C#/.NET开发问题
2

Delegate.CreateDelegate() 和泛型:错误绑定到目标方法
Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)...
2023-11-11 C#/.NET开发问题
14