title: How to retrieve all certificates in your X509Store
body: <p>I am using the following code to retrieve all certificates in my PC from an asp.net webapp. The certificates collection is empty, and I can't understand why. </p>
  
  <p>I tried impersonating my own user account and I didn't succeed as well. What am I doing wrong?</p>
  
  <pre><code>var store = new X509Store(StoreLocation.CurrentUser); //StoreLocation.LocalMachine fails too
  var certificates = store.Certificates;
  foreach (var certificate in certificates)
  {
      var friendlyName = certificate.FriendlyName;
      Console.WriteLine(friendlyName);
  }
  
  //original problem: fetch a single certificate by its subject name
  X509Certificate2 clientCertificate = CertificateUtility.GetCertificate(StoreName.My, StoreLocation.CurrentUser,  "CN=mypc.domainname"); //returns null :(
  </code></pre>