views:

312

answers:

1

Hi,

I'm loading a .p7b certificate file into memory and then calling CertCreateCertificateContext on it, but it fails with the error "ASN1 bad tag value met.".

The call look like this:

m_hContext = CertCreateCertificateContext(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, pbCertEncoded, dwCertEncodedLen);

This returns NULL and GetLastError() returns the error mentioned above.

I created the certificate file by dragging a certificate out of the settings in IE, which then does an automatic export to a file.

What am I doing wrong?

Thanks!

A: 

Try to open your certificate by some asn.1 editor. For example using this one ASN.1 editor Probably your certificate has been exported incorrectly or size of the certificate you pass to the api is wrong... Rather the second one option (incorrect cert construction or passing)

I found here the info that the encoding you try to use is not fully supported (see possible error values)

Alek

Alex Stankiewicz
I didn't solve it but thanks for suggestion.