Azure函数中访问证书

Azure函数中访问证书

本文介绍了从C#Azure函数中访问证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从我的Azure功能访问证书.

I need to access a certificate from my Azure Function.

我按照运行时错误加载证书中概述的步骤进行操作Azure Functions ,但没有成功.

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,并将其设置为*或所需证书的标志,但无济于事.

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.

消费计划尚不支持

客户端证书,仅应用服务计划中不支持.在我们的仓库此处中,对此问题进行了跟踪.我们正在努力-请关注该问题的状态.谢谢.

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

07-26 02:18