CryptDecodeObjectEx Bad Tag ERROR (0x8009310b)

4

I have a .cer file. I can read it and write a buffer via ReadFile() function. Now I have buffer and datalen which I had.

And I use that buffer and len for calling CryptDecodeObjectEx() function like below line

if ( !CryptDecodeObjectEx( X509_ASN_ENCODING, 
                           X509_PUBLIC_KEY_INFO, 
                           (BYTE* )pemPubKey, 
                           readLen, 
                           CRYPT_DECODE_ALLOC_FLAG, 
                           NULL, 
                           &publicKeyInfo, 
                           (DWORD *)&publicKeyInfoLen ) )

But when I run it through debug, I get 0x8009310B error code via GetLastError() func.

How can I fix it? Thanks for your advice.

Additional Information

  • If I use X509_ANY_STRING instead of X509_PUBLIC_KEY_INFO; it works. But it does not fill my publicKeyInfo struct. Because of that I cannot get public key in it .
  • I have a DER formatted certificate.
c
windows
winapi
getlasterror
asked on Stack Overflow Sep 24, 2014 by ceyun • edited Sep 24, 2014 by ceyun

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0