1

For this certificate, what should be the arguments of the following call? I tried the following and it did not work.

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

enter image description here

ajeh
  • 2,652
  • 2
  • 34
  • 65
  • are you receiving an error of any kind? – Marshall Tigerus May 25 '17 at 16:40
  • Also, you may want to tinker with your code and test that the cert is where you expect it and is acessible. This: https://stackoverflow.com/questions/4729302/how-to-retrieve-all-certificates-in-your-x509store shows how to retrieve all certs from the store. – Marshall Tigerus May 25 '17 at 16:48
  • The error is kind of obvious: certificate could not be found. – ajeh May 25 '17 at 16:57

1 Answers1

1

The Certificate Tool's TrustedRootCertificateAuthorities store name maps to StoreName.Root in .NET X509 API.

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

Or:

X509CertificateInitiatorClientCredential.ClientCertificate.SetCertificate(
     StoreLocation.LocalMachine
    ,StoreName.Root
    ,X509FindType.FindBySubjectName
    ,"MPCA" // Without CN=
);
ajeh
  • 2,652
  • 2
  • 34
  • 65