On Wed, Aug 19, 2009, barcaroller wrote:
>
> I have a PEM-format server certificate that I need to convert to a binary
> structure as defined in section 7.4.2. (Server Certificate) of RFC5246
> (TLS v1.2).
>
>
> Server certificate (in PEM format), residing as a
> text file in the filesystem
> |
> |
> V
> Load into buffer in memory with structure as defined in RFC5246:
>
> opaque ASN.1Cert<1..2^24-1>;
>
> struct {
> ASN.1Cert certificate_list<0..2^24-1>;
> } Certificate;
>
> certificate_list
>
>
>
> Also, I will need to do the reverse: converting a binary buffer in memory
> (with the structure above) into a PEM-format server certificate.
>
> My question is: are there OpenSSL routines that do this? I have looked at
>
> X509 *PEM_read_bio_X509(BIO *bp, X509 **x,
> pem_password_cb *cb, void *u);
>
> but it is not clear to me how I should handle (BIO* bp). If this function
> indeed does what I need, how would I convert my memory buffer to a BIO, and
> vice versa?
>
>
The functions d2i_X509() and i2d_X509() will do what you want, check out the
manual pages and the FAQ to avoid a common mistake with these functions.
Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [email protected]
Automated List Manager [email protected]