我在从我的代码管理 Azure 证书时遇到了一些困难。事实上,我正在尝试使用 Azure REST 服务 API(例如创建 HTTP 请求)来从我的 Azure 网站了解我的服务状态。
它在本地调试中运行良好,但我的网络角色接缝对证书管理器有一些限制。贝娄是我所做的:
// this method stores a certificate from the resources
// to the local certificates manager
private X509Certificate2 StoreCertificate(Certificates certName)
{
X509Certificate2 newCert = null;
// get certificate from resources
newCert = this.GetCertificateFromResources(certName);
// store it into the local certificate manager
if (newCert != null)
{
var store = new X509Store(
StoreName.TrustedPeople,
StoreLocation.LocalMachine
);
store.Open(OpenFlags.ReadWrite);
store.Add(newCert);
}
// reset ref and try to load it from manager
newCert = null;
newCert = this.GetCertificate(certName);
return newCert;
}
当我尝试添加证书时,会附加访问被拒绝错误。
任何想法 ?我可以将证书存储到 Azure VM 中吗?我应该使用特殊的位置来存储这些吗?