You can use the X509Store class to determine which certificates are installed in a particular certificate store. There are various ways to search for certificates (for example, subject name, issuer name, serial number, etc.).
For example, to open the current user store and search for a certificate by topic name:
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine); try { store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly); X509Certificate2Collection foundCerts = store.Certificates.Find(X509FindType.FindBySubjectName, "MY CERTIFICATE SUJECT NAME", true); if (foundCerts.Count == 0) { // Cert not found } else { X509Certificate2 cert = foundCerts[0]; // Get first matching certificate } } finally { store.Close(); }
source share