以下代码在Azure App服务上运行时运行并获取App数据。 在本地,它会抛出未经授权的证书。 有什么理由吗?
如果我从字符串本地创建证书,它可以正常工作。
public static CertificateCloudCredentials CredentialsProd;
X509Store certStore = new X509Store(StoreName.My, StoreLocation.LocalMachine);
certStore.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certCollection = certStore.Certificates.Find(
X509FindType.FindByThumbprint,
prodThumbprint,
false);
if (certCollection.Count > 0)
{
X509Certificate2 cert = certCollection[0];
Credentials = new CertificateCloudCredentials(SUBSCRIPTION_ID, cert);
}
certStore.Close();
using (var client = new ComputeManagementClient(Credentials))
{
var t = client.HostedServices.GetDetailedAsync(serviceName, CancellationToken);
HostedServiceGetDetailedResponse detailedResponse = t.Result;
}
答案 0 :(得分:0)
本地计算机上的证书必须安装为.Pfx 就像在Azure中一样。