Hi, I think you could use the i2d_X509_bio and d2i_X509_bio function that help using BIO and X509 struture.
from openssl/x509.h #define d2i_X509_bio(bp,x509) (X509 *)ASN1_d2i_bio((char *(*)())X509_new, \ (char *(*)())d2i_X509, (bp),(unsigned char **)(x509)) #define i2d_X509_bio(bp,x509) ASN1_i2d_bio(i2d_X509,bp,(unsigned char *)x509) hope it could help Fred -----Original Message----- From: Dr. Stephen Henson [mailto:[EMAIL PROTECTED] Sent: Thu 12/1/2005 3:01 PM To: openssl-users@openssl.org Cc: Subject: Re: load x509 certificate from base 64 string into X509 structure On Thu, Dec 01, 2005, Rajeshwar Singh Jenwar wrote: > extern X509 *mem2x509_pem(char *cert) > > { > X509 *x509= NULL; > BIO *bio = NULL; > int len = -1; > bio = BIO_new(BIO_s_mem()); > if (!bio) > goto end; > len = BIO_write(bio, cert, strlen(cert)); > if (len == -1) > goto end; > x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL); > > if(!x509) > goto end; > end: > if(bio) BIO_free(bio); > > return x509; > } > Its easier and more efficient to create the memory BIO with: bio = BIO_new_mem_buf(cert, -1); 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 openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED] ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]