Posted By

hairajeshk on 02/18/11


Tagged

read Information certification


Versions (?)

Accessing certification using c#


 / Published in: C#
 

URL: http://www.codequake.com/post/2010/08/12/How-to-access-certificates-using-C.aspx

http://www.codequake.com/post/2010/08/12/How-to-access-certificates-using-C.aspx

  1. private static void AccessPersonalStore()
  2. {
  3. // Access the personal store
  4. X509Store store = new X509Store(StoreName.My);
  5. // Open the store as ReadOnly
  6. store.Open(OpenFlags.ReadOnly);
  7.  
  8. if (store.Certificates.Count > 0)
  9. {
  10. foreach (X509Certificate2 cert in store.Certificates)
  11. {
  12. Console.WriteLine("Certificate algorithm: " + cert.SignatureAlgorithm.FriendlyName);
  13. Console.WriteLine("Certificate issuer: " + cert.IssuerName);
  14. Console.WriteLine("Certificate serial: " + cert.SerialNumber);
  15. Console.WriteLine("Certificate valid after: " + cert.NotBefore.ToShortDateString());
  16. Console.WriteLine("Certificate valid until: " + cert.NotAfter.ToShortDateString());
  17. // etc... Many properties and methods are available.
  18. Console.WriteLine();
  19. Console.WriteLine("----------------------");
  20. Console.WriteLine();
  21. }
  22.  
  23. Console.ReadLine();
  24. }
  25.  
  26. }

Report this snippet  

You need to login to post a comment.