Azure 不返回上传的证书
Azure Not Returning uploded certificates
我已经通过 azure 新门户上传了证书,但我没有得到这些证书这里是我的代码
var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certificates = store.Certificates;
try
{
}
finally
{
store.Close();
}
return certificates;
这些是我经常得到的证书
我也关注了这篇文章https://azure.microsoft.com/en-us/blog/using-certificates-in-azure-websites-applications/
有人知道我没有获得所有证书的原因以及我获得这些证书的原因吗??请帮忙
好吧,我正在使用我在某处找到的这个功能并且工作正常。如果您已正确上传所有证书,请尝试运行这段代码。我知道它看起来一样,但你真的看不出来。
private X509Certificate2 GetStoreCertificate(string thumbprint)
{
List<StoreLocation> locations = new List<StoreLocation> { StoreLocation.CurrentUser, StoreLocation.LocalMachine };
foreach (var location in locations)
{
Console.WriteLine("location: " + location.ToString());
X509Store store = new X509Store("My", location);
try
{
Console.WriteLine("Try, store.Open...");
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
Console.WriteLine("store.Opened..." + store.Certificates.Count.ToString());
foreach (X509Certificate2 cert in store.Certificates)
{
Console.WriteLine("X509Certificate2 Thumbprint : " + cert.Thumbprint);
}
foreach (X509Certificate cert in store.Certificates)
{
Console.WriteLine("X509Certificate Thumbprint : " + cert.Issuer);
}
X509Certificate2Collection certificates = store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false);
Console.WriteLine("Finding certificate.." + certificates.Count.ToString());
if (certificates.Count == 1)
{
Console.WriteLine("Atleast one found!!!");
return certificates[0];
}
}
finally
{
store.Close();
}
}
throw new ArgumentException(string.Format("A Certificate with Thumbprint '{0}' could not be located.", thumbprint));
}
instead of geeting all certificates i just received these 4, and in the local enviorment i get all certificates which are install on my machine
根据我的测试,the article 在您的回复中帮助我们在 Azure Web 应用程序中使用证书。但是我们只能查询符合以下条件的证书:
1) 证书已上传到 Azure Web 应用
2) 在 Azure 门户中设置 WEBSITE_LOAD_CERTIFICATES 并将其值设置为证书指纹
这与您在本地计算机上的测试不同,因为 Azure Web 应用程序 运行 在沙盒中。有关 Azure Web 应用程序沙箱的更多信息,请参阅 this article。
我已经通过 azure 新门户上传了证书,但我没有得到这些证书这里是我的代码
var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certificates = store.Certificates;
try
{
}
finally
{
store.Close();
}
return certificates;
这些是我经常得到的证书
我也关注了这篇文章https://azure.microsoft.com/en-us/blog/using-certificates-in-azure-websites-applications/
有人知道我没有获得所有证书的原因以及我获得这些证书的原因吗??请帮忙
好吧,我正在使用我在某处找到的这个功能并且工作正常。如果您已正确上传所有证书,请尝试运行这段代码。我知道它看起来一样,但你真的看不出来。
private X509Certificate2 GetStoreCertificate(string thumbprint)
{
List<StoreLocation> locations = new List<StoreLocation> { StoreLocation.CurrentUser, StoreLocation.LocalMachine };
foreach (var location in locations)
{
Console.WriteLine("location: " + location.ToString());
X509Store store = new X509Store("My", location);
try
{
Console.WriteLine("Try, store.Open...");
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
Console.WriteLine("store.Opened..." + store.Certificates.Count.ToString());
foreach (X509Certificate2 cert in store.Certificates)
{
Console.WriteLine("X509Certificate2 Thumbprint : " + cert.Thumbprint);
}
foreach (X509Certificate cert in store.Certificates)
{
Console.WriteLine("X509Certificate Thumbprint : " + cert.Issuer);
}
X509Certificate2Collection certificates = store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false);
Console.WriteLine("Finding certificate.." + certificates.Count.ToString());
if (certificates.Count == 1)
{
Console.WriteLine("Atleast one found!!!");
return certificates[0];
}
}
finally
{
store.Close();
}
}
throw new ArgumentException(string.Format("A Certificate with Thumbprint '{0}' could not be located.", thumbprint));
}
instead of geeting all certificates i just received these 4, and in the local enviorment i get all certificates which are install on my machine
根据我的测试,the article 在您的回复中帮助我们在 Azure Web 应用程序中使用证书。但是我们只能查询符合以下条件的证书:
1) 证书已上传到 Azure Web 应用
2) 在 Azure 门户中设置 WEBSITE_LOAD_CERTIFICATES 并将其值设置为证书指纹
这与您在本地计算机上的测试不同,因为 Azure Web 应用程序 运行 在沙盒中。有关 Azure Web 应用程序沙箱的更多信息,请参阅 this article。