2011-06-23 12 views

答えて

6

X509Storeクラスを使用すると、システム上の証明書を検索できます。以下のコードサンプルは、現在のユーザーのパーソナルストア内のサブジェクト名 "XYZ"で証明書を検索します。

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. 
} 
関連する問題