2017-05-25 113 views
0

對於這個證書,以下調用的參數應該是什麼?我嘗試了以下,但沒有奏效。該證書應該是什麼SetCertificate()參數?

X509CertificateInitiatorClientCredential.ClientCertificate.SetCertificate(
    StoreLocation.LocalMachine 
    ,StoreName.CertificateAuthority 
    ,X509FindType.FindBySubjectName 
    ,"CN=MPCA" // also tried without CN= 
); 

enter image description here

+0

您收到任何類型的錯誤? –

+0

此外,您可能需要修改代碼並測試證書是否在您期望的範圍內,並且是不可訪問的。這:https://stackoverflow.com/questions/4729302/how-to-retrieve-all-certificates-in-your-x509store顯示如何從商店檢索所有證書。 –

+0

錯誤很明顯:無法找到證書。 – ajeh

回答

0

證書工具的TrustedRootCertificateAuthorities商店名稱映射到StoreName.Root在.NET API X509。

X509CertificateInitiatorClientCredential.ClientCertificate.SetCertificate(
    StoreLocation.LocalMachine 
    ,StoreName.Root 
    ,X509FindType.FindBySerialNumber 
    ,"FA###########434" // serial found by enumerating all certs 
); 

或者:

X509CertificateInitiatorClientCredential.ClientCertificate.SetCertificate(
    StoreLocation.LocalMachine 
    ,StoreName.Root 
    ,X509FindType.FindBySubjectName 
    ,"MPCA" // Without CN= 
); 
相關問題