title: Cant access certificates in X509Store from asp.net core 2.1 with thumbprints
body: <p>I have strange problem when accessing X509Store from IIS. I can't look them up.<br />
  If I access both the rp cert and ca cert from powershell both are there,</p>
  <p>dir cert: -Recurse | Where-Object { $_.Thumbprint -like &quot;<em>thumprintstring</em>&quot; }</p>
  <p>I have checked that the thumbprints don't have a hidden char in the beginning of thumbprint<br />
  I have set that the certificates are exportable when I install them<br />
  I have for the moment set it accessable for everyone(its a certificate to a test server) in certficate
  store</p>
  <p>This is code I use</p>
  <pre><code>                StoreLocation location = certificateConfig.UseCurrentUserStoreLocation ? StoreLocation.CurrentUser : StoreLocation.LocalMachine;
   
                  using (var clientCertStore = new X509Store(StoreName.My, location))
                  {
                      clientCertStore.Open(OpenFlags.ReadOnly);
  
                      //Search for the client cert
                      X509Certificate2 rpCert = GetCertByThumbprint(clientCertStore, certificateConfig.RpCertThumbprint);
                      if (rpCert == null)
                      {
                          throw new InvalidOperationException(&quot;No rp cert found for specified thumbprint #&quot; + certificateConfig.RpCertThumbprint +&quot;# &quot;+location);
                      }
                      ClientCertificates.Add(rpCert);
                  }
  &lt;snip&gt;
          private X509Certificate2 GetCertByThumbprint(X509Store certStore, string thumbprint)
          {
              var certs = certStore.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false);
  
              return certs.Count &gt; 0 ? certs[0] : null;
          }
  </code></pre>
  <p>The rpcert is always null whatever i try.<br />
  Do I need another way to open up the store from IIS?<br />
  Any ideas or suggestions?  What am I missing?</p>