----- Original Message ----- 
From: Dr Stephen Henson <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 06, 2000 3:38 PM
Subject: Re: the API to load X509 from char*


> Howard Chu wrote:
> > 
> > Yes, it's quite easy. This works for me in 0.9.4:
> > (char *buf; int len; values should already be set)
> > ...
> > BIO *bi = BIO_new(BIO_s_mem());
> > BUF_MEM bf;
> > X509 *x;
> > bf.length = len;
> > bf.data = buf;
> > bf.max = bf.length;
> > BIO_set_mem_buf(bi, &bf, 0);
> > x = PEM_read_bio_X509(bi, NULL, NULL, NULL);
> > 
> 
> Yes that will work. However you should also do
> BIO_set_close(bi, BIO_NOCLOSE);
> otherwise it will try to Free() the buffer when you do BIO_free(bi);
> 
> Steve.
The most convinient would be probably this way:
BIO *bi = BIO_new_mem_buf(buf, len);
X509 *x;
x = PEM_read_bio_X509(bi, NULL, NULL, NULL);
BIO_free (bi);
Note: you can use -1 in place of len for zero-terminated strings.


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to