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

Joe*_*eky 4 azure azure-worker-roles

我有一个Azure Worker角色,我希望调用管理服务(例如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");
}
Run Code Online (Sandbox Code Playgroud)

没有例外,只是没有找到证书.任何人都能解释我需要做什么吗?

Joe*_*eky 8

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