Changed code to: bio = BIO_new(BIO_f_base64()); BIO_push(bio, mbio); int bytes_stored = i2d_PKCS12_bio(bio, p12); BIO_flush(bio);
No effect still. I was also searching the archives and found this: http://www.mail-archive.com/[EMAIL PROTECTED]/msg36055.html This person was seeing only 9 bytes out of expected 13. I could not see a resolution to the above problem and I am leading to believe that my problem could be very similar to his. Thanks On Thu, 9 Sep 2004 20:56:20 +0200, Dr. Stephen Henson <[EMAIL PROTECTED]> wrote: > > > On Thu, Sep 09, 2004, Smith Baylor wrote: > > > A PKCS12 object is encrypted with a shared secret. When I use the > > function i2d_PKCS12_fp() to write to a file, it works, but, when I use > > this to store in a BIO and convert this into base64, it does only > > 2/3rds of it. Why is this? Any thoughts or pointers? > > > > Thanks > > > > > > > > On Thu, 9 Sep 2004 08:32:36 -0700, Smith Baylor <[EMAIL PROTECTED]> wrote: > > > BIO *mbio, *b64bio, *bio; > > > > > > mbio = BIO_new(BIO_s_mem()); > > > b64bio = BIO_new(BIO_f_base64()); > > > bio = BIO_push(b64bio, mbio); > > > int bytes_stored = i2d_PKCS12_bio(bio, p12); > > > BIO_flush(mbio2); > > > > > > BIO_get_mem_data(mbio, (unsigned char *)&p12_data_tmp); > > > p12_data = (unsigned char*)OPENSSL_malloc(bytes_stored + 1); > > > strncpy(p12_data, p12_data_tmp, bytes_stored); > > > p12_data[bytes_stored] = '\0'; > > > > > > bytes_stored gives me 4030 bytes, but, when I try to print or save the > > > p12_data, I am able to get only 3000 bytes and the program stops. > > > What am I doing wrong? > > > > > At least one problem is that you need to call BIO_flush() on the BIO chain > (bio in your example above) not the memory BIO. > > Steve. > -- > Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage > OpenSSL project core developer and freelance consultant. > Funding needed! Details on homepage. > Homepage: http://www.drh-consultancy.demon.co.uk > ______________________________________________________________________ > OpenSSL Project http://www.openssl.org > User Support Mailing List [EMAIL PROTECTED] > Automated List Manager [EMAIL PROTECTED] > ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]