Getting Windows Certificate using C# By Serial Number

After installing a certificate in windows store, you need to use it in your code to encrypt or decrypt the message.

Certificate

You can get the serial number of the certificate by double click on the certificate.

X509Store store = new X509Store(StoreLocation.LocalMachine); 
store.Open(OpenFlags.ReadOnly); 
string sn = " put here your certificate serial number "; 
X509Certificate2Collection coll = 
store.Certificates.Find(X509FindType.FindBySerialNumber, sn, true); 
if (coll[0] != null)
   X509Certificate2 myCert = coll[0];
Advertisements