public static List<string> GetCertNamesFromStore(string search) { X509Store store = new X509Store("My"); try { store.Open(OpenFlags.ReadOnly); X509Certificate2Collection certCollection = store.Certificates; X509Certificate2Collection currentCerts = certCollection.Find(X509FindType.FindByTimeValid, DateTime.Now, false); var res = new List<string>(); foreach (X509Certificate2 s in certCollection) { if (search=="") res.Add(GetSubjectCN(s)); else if (s.SubjectName.Name.Contains(search)) res.Add(GetSubjectCN(s)); } return res; } finally { store.Close(); } }
C# How to get all certificates from "My" Store
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: only a member of this blog may post a comment.