>       From: [email protected] On Behalf Of
[email protected]
>       Sent: Thursday, 02 July, 2009 06:53
<snip>
>         FILE *fp = 0;
>         char derCert[MAX_CERT_LEN];
>         long len;
        
>         if (fp = fopen("../der.cer", "rb")) {
>           len=fread(derCert, 1, MAX_CERT_LEN - 1, fp);
>           derCert[len] = '\0';
>          }

DER data is not a C string; adding a null to 'terminate' it 
will almost never help. To clarify/document this, I think 
it is better style to use unsigned-char arrays (and pointers) 
for it, although plain-char will work.

>         //This is working ...[ BIO_new file ]...

>           //This is not working
>             if(( bioCert = BIO_new_mem_buf(derCert, -1)) == NULL)
>             { ...[error]... }

DER data is not a C string; pass len from above instead of -1.

If you (convert to hex and) decode your error code, you get
error:0D06B08E:asn1 encoding routines:ASN1_D2I_READ_BIO:not enough data
which could have been a clue.

Incidentally, you don't need a mem-BIO to decode (or encode) exact 
in-memory buffers; you can use the basic d2i and i2d routines.



______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [email protected]
Automated List Manager                           [email protected]

Reply via email to