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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s