Hi Fred,
These functions i2d_X509_bio and d2i_X509_bio are used for X509 cerificates in DER format.
But the requirement was to read X509 cert in PEM format from memory.
Hi Steve,
I got ur point bio = BIO_new_mem_buf(cert, -1);
will be more efficient becuase it avoid BIO_write by just assinging
(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
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;
>
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(bi