gpt4 book ai didi

azure - 无法从 Azure 辅助角色中加载证书实例

转载 作者:行者123 更新时间:2023-12-04 23:26:55 25 4
gpt4 key购买 nike

我有一个 Azure 辅助角色,我希望调用管理服务(例如 REST API)并收集有关相关服务的信息。但是,当我尝试加载我的证书时,它找不到它。以下是我遵循的步骤:

1. 我使用 MakeCert 创建了一个证书,并通过门户将其注册为我的管理证书

makecert -r -pe -a sha1 -n "CN=MyCnName" -ss My -len 2048 -sp "Microsoft Enhanced RSA and AES Cryptographic Provider" -sy 24 MyCert.cer

2. 在我的本地计算机上安装了证书,一切正常。在本地运行辅助角色时,我可以毫无问题地调用管理服务。

3.从我的机器导出证书并通过门户将导出的证书注册到目标托管服务下

4.部署角色。当角色启动时,它无法找到证书。

这是我用来查找证书的代码摘录。

// Open the certificate store for the current user.
var certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser); // I also tried localmachine
certStore.Open(OpenFlags.ReadOnly);

// Find the certificate with the specified subject.
X509Certificate2Collection certCollection = certStore.Certificates.Find(
X509FindType.FindBySubjectName,
_myConfiguration.SubjectName,
false);


if (certCollection == null || certCollection.Count < 1)
{
// Find the certificate with the specified thumbprint.
certCollection = certStore.Certificates.Find(
X509FindType.FindByThumbprint,
_myConfiguration.ThumbPrint,
false);
}

// Close the certificate store.
certStore.Close();

// Check to see if a matching certificate was found.
if (certCollection.Count == 0)
{
_logger.Warn("No certificate found");
}

没有异常(exception),只是没有找到证书。谁能告诉我我需要做什么?

最佳答案

解决了问题...除了在门户中配置证书之外,我还需要将证书详细信息(例如名称、存储和指纹)添加到下的 Azure 项目角色设置中证书选项卡。

关于azure - 无法从 Azure 辅助角色中加载证书实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11494922/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com