x.509 certificate - can't read CN when subject starts with Email

Go To StackoverFlow.com

0

I'm trying to get a Certificate from an X509Store object, by subjectName using X509FindType.FindBySubjectName. I'm able to see the correct cert in the innerList array within the store object when debugging, but for some reason am not able to instantiate an X509CertificateCollection object when trying to find the certificate by SubjectName.

X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly);
X509CertificateCollection certs = store.Certificates.Find(X509FindType.FindBySubjectName, Vendor.CertName, true);

I noticed that the subject starts with an email address attribute, where all other certs in the store (that I am able to find) begin with Certificate Name (CN).

Subject example:

E=someDude@theirSite.com, CN=Our Technology, L=Tampa, S=FL, C=US

Other certs that work look like this:

CN=Some Certificate Authority, OU=Ecommerce, O=Company Inc, C=US

If the subject starts with the email attribute, am I supposed to do something differently to find the cert by subjectName? If not, any suggestions as to how I can retrieve it from the certificate store?

Thanks

2012-04-04 21:17
by Mark B


0

Turns out this is a root cert that was installed in the personal certificates folder. Moving it to the root, and using StoreLocation.Root did the trick.

2012-04-04 22:43
by Mark B
Ads