I have a B1 App Service in Azure and I've installed my certificate in it as shown below:
When I try to get the certificate, it can't find it. As if no certificates are installed. Here's my code:
using (X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser))
{
certStore.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certCollection = certStore.Certificates.Find(
X509FindType.FindByThumbprint,
certificateThumbprint,
false);
if (certCollection.Count > 0)
{
return certCollection[0];
}
throw new Exception("Certificate not found!");
}
I've verified the certificate thumbprint and even tried putting it hard-coded as string.
When I try to print the number of certificates in the store like this:
Console.WriteLine("certStore.Certificates.Count : " + certStore.Certificates.Count);
it returns zero certificates.
I also tried changing StoreName
and StoreLocation
- still same result. And even when not giving any StoreName
or StoreLocation
it still doesn't find any certificates.