0

I'm having trouble accessing a certificate I uploaded to Azure to manage my account in code.

I've followed this tutorial: http://azure.microsoft.com/blog/2014/10/27/using-certificates-in-azure-websites-applications/

Uploaded the cert to Azure settings: azure settings with cert I uploaded

I've configured a web app on Azure to be a basic plan and uploaded the pfx of that same cert to the web app: Cert on the web app

Then I run this code (both locally and after publishing):

  X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
  certStore.Open(OpenFlags.ReadOnly);
  X509Certificate2Collection certCollection = certStore.Certificates.Find(
                             X509FindType.FindByThumbprint,
                             // Replace below with your cert's thumbprint
                             “XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”,
                             false);
  // Get the first cert with the thumbprint
  if (certCollection.Count > 0)
  {
    X509Certificate2 cert = certCollection[0];
    // Use certificate
    Console.WriteLine(cert.FriendlyName);
  }
  certStore.Close();

Locally on my development machine, this runs fine, I send a create database command off to Azure REST API and voila, my command works.

When I publish however, certCollection is empty so I cannot attempt to issue commands against the Azure Management APIs.

Why is this happening?

Smithy
  • 2,170
  • 6
  • 29
  • 61
  • I bet it is a copy/paste issue - this works for me. Double check your thumbprint. Also, did you copy the thumbprint from the MMC certificate manager snap-in and paste it into your code? If so, then I bet you picked up the hidden characters that are at the beginning of the thumbprint. – Rick Rainey May 30 '15 at 19:55
  • Locally this works fine though? I copied the thumbprint from azure site several times also lol – Smithy May 30 '15 at 19:58
  • Did you also add the app setting in the app settings section? – Rick Rainey May 30 '15 at 22:30
  • 2
    This is the app setting: "WEBSITE_LOAD_CERTIFICATES". Add this in the app settings section and set the value to your thumbprint. – Rick Rainey May 31 '15 at 01:16

0 Answers0