title: ASP.NET Core Web App: How to get a client's certificate
body: <p>My goal is to obtain the public key associated with a particular browser's/client's certificate info at runtime, and eventually store these public keys. </p>
  
  <hr>
  
  <p>Here's a high-level example.</p>
  
  <p><strong>Server</strong>: ASP.NET Core Web App, hosted in Azure</p>
  
  <p><strong>Device1</strong>: a Chrome browser, running on a Windows 10 laptop</p>
  
  <p><strong>Device2</strong>: a Firefox browser, running on a Google Pixel 2</p>
  
  <hr>
  
  <ul>
  <li><strong>Device1</strong> makes a GET request to <strong>Server</strong>; some code running on <strong>Server</strong> gets the public key of the cert used by Chrome; the public key is "1122"</li>
  <li><strong>Device2</strong> makes a GET request to <strong>Server</strong>; some code running on <strong>Server</strong> gets the public key of the cert used by Firefox; the public key is "3344"</li>
  </ul>
  
  <hr>
  
  <h1>What code do I need to write to get "1122" and "3344"?</h1>
  
  <p>I've looked at the <strong>X509Certificate2</strong> class, but all the examples I've seen are kind of confusing, and don't accomplish what I want (also, I've <em>never</em> messed with SSL certs in code before). I've also seen the <strong>HttpClientCertificate</strong> class, however I can't figure out how to use that class. I feel like there's a library out there that I'm just not seeing.</p>