2011-06-23 40 views

Trả lời

6

Bạn có thể sử dụng lớp X509Store để tìm kiếm chứng chỉ trên hệ thống. Mẫu mã bên dưới tìm thấy chứng chỉ theo tên chủ đề của "XYZ" trong Cửa hàng cá nhân của người dùng hiện tại.

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. 
} 
Các vấn đề liên quan