in SampleCPMProject/CpmClient/AadAuthentication.cs [42:61]
private static X509Certificate2 GetCertificateFromStore(string certThumbprint)
{
var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadOnly);
var certs = store.Certificates.Find(X509FindType.FindByThumbprint, certThumbprint, false);
if (certs.Count == 1)
{
return certs[0];
}
if (certs.Count > 1)
{
throw new System.Exception($"More than one certificate with thumbprint {certThumbprint} " +
"found in LocalMachine store location");
}
throw new System.Exception($"No certificate found with thumbprint {certThumbprint} " +
"in LocalMachine store location");
}