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)
没有例外,只是没有找到证书.任何人都能解释我需要做什么吗?
归档时间: |
|
查看次数: |
2855 次 |
最近记录: |