title: No certificate found
body: <p>I'm trying to authenticate a user for the Azure management API. I'm following this tutorial for that:
  <a href="http://msdn.microsoft.com/en-us/library/windowsazure/ee460782.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windowsazure/ee460782.aspx</a></p>
  
  <p>However, when I execute it, I always get a "certificate not found" error. What could cause this? My code is exactly the same as in the example:</p>
  
  <pre><code>        // Values for the subscription ID and List Hosted Services operation.
          // 
          string subscriptionId = "****************";
  
          // The opperation to be performed. This value can be modified to reflect the operation being performed.
          string operationName = "hostedservices";
  
          // Build a URI for https://management.core.windows.net/&lt;subscription-id&gt;/services/&lt;operation-type&gt;
          Uri requestUri = new Uri("https://management.core.windows.net/"
                                  + subscriptionId
                                  + "/services/"
                                  + operationName);
  
          // Create the request and specify attributes of the request.
          HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(requestUri);
  
          // Define the requred headers to specify the API version and operation type.
          request.Headers.Add("x-ms-version", "2010-10-28");
          request.Method = "GET";
          request.ContentType = "application/xml";
  
  
          // The thumbprint value of the management certificate.
          // You must replace the string with the thumbprint of a 
          // management certificate associated with your subscription.
          string certThumbprint = "*************";
  
          // Create a reference to the My certificate store.
          X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
  
          // Try to open the store.
          try
          {
              certStore.Open(OpenFlags.ReadOnly);
          }
          catch (Exception e)
          {
              if (e is CryptographicException)
              {
                  Console.WriteLine("Error: The store is unreadable.");
              }
              else if (e is SecurityException)
              {
                  Console.WriteLine("Error: You don't have the required permission.");
              }
              else if (e is ArgumentException)
              {
                  Console.WriteLine("Error: Invalid values in the store.");
              }
              else
              {
                  throw;
              }
          }
  
          // Find the certificate that matches the thumbprint.
          X509Certificate2Collection certCollection = certStore.Certificates.Find(X509FindType.FindByThumbprint, certThumbprint, false);
          certStore.Close();
  
          // Check to see if our certificate was added to the collection. If no, throw an error, if yes, create a certificate using it.
          if (0 == certCollection.Count)
          {
              throw new Exception("Error: No certificate found containing thumbprint " + certThumbprint);
          }
  
          // Create an X509Certificate2 object using our matching certificate.
          X509Certificate2 certificate = certCollection[0];
  
          // Attach the certificate to the request.
          request.ClientCertificates.Add(certificate);
  
          try
          {
              // Make the call using the web request.
              HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  
              // Display the web response status code.
              Console.WriteLine("Response status code: " + response.StatusCode);
  
              // Display the request ID returned by Windows Azure.
              if (null != response.Headers)
              {
                  Console.WriteLine("x-ms-request-id: "
                  + response.Headers["x-ms-request-id"]);
                  Console.ReadKey();
              }
  
              // Parse the web response.
              Stream responseStream = response.GetResponseStream();
              StreamReader reader = new StreamReader(responseStream);
  
              // Display the raw response.
              Console.WriteLine("Response output:");
              Console.WriteLine(reader.ReadToEnd());
              Console.ReadKey();
  
              // Close the resources no longer needed.
              response.Close();
              responseStream.Close();
              reader.Close();
          }
          catch (Exception e)
          {
              Console.WriteLine(e.Message);
          }
  
      }
  </code></pre>