You can use the X509Store class to search for certificates in the system. Below the sample code finds a certificate by the name of the subject "XYZ" in the personal store of the current user.
System.Security.Cryptography.X509Certificates.X509Store store = new System.Security.Cryptography.X509Certificates.X509Store(StoreName.My, StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly); // Dont forget. otherwise u will get an exception. X509Certificate2Collection certs = store.Certificates.Find(X509FindType.FindBySubjectName,"XYZ",true); if(certs.Count > 0) { // Certificate is found. } else { // No Certificate found by that subject name. }
source share