CryptDecodeObjectEx Bad Tag ERROR (0x8009310b)

I have a .cer file. I can read it and write a buffer through the ReadFile () function. Now I have the buffer and datalen that I had.

And I use this buffer and len to call 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 via debug I get error code 0x8009310B using GetLastError () function.

How can I fix this? Thank you for your advice.

Additional Information

  • If I use X509_ANY_STRING instead of X509_PUBLIC_KEY_INFO; it works. But it doesn't populate my publicKeyInfo structure. Because of this, I cannot get the public key in it.
  • I have a DER formatted certificate.
+3
c windows winapi getlasterror


source to share


No one has answered this question yet

Check out similar questions:

951
Node.js / Windows Error: ENOENT, stat 'C: \ Users \ RT \ AppData \ Roaming \ npm'
840
Error: Could not find vcvarsall.bat
3
Public Key Bytes from SecKeyRef
2
CppUTest: how to pass more data to a specific layout?
2
pem file from Microsoft Serialized Store (SST) files
1
copying from buffer to buffer with a for loop running in all cases except 0,
1
server using overlapped named pipe: how to use GetOverlappedResult () with ReadFile ()?
1
CryptEncrypt does not work with NTE_BAD_LEN
1
Check file is correct with sha1withRsa via openssl functions
0
how to extract PKCS12 certificate from binary encoded character buffer in c ++.



All Articles
Loading...
X
Show
Funny
Dev
Pics