Hi!

I think something along the following should do the trick:

// Create a memory buffer BIO
BIO* certBIO = BIO_new_mem_buf(buffer, bufferLength);

// Read request from BIO
X509* cert = PEM_read_bio_X509(certBIO, 0, 0, 0);

// get length of DER encoding
int encLength = i2d_X509(cert, 0);

// Create a vector to hold our DER data and reserve memory
vector<unsigned char> encBuffer;
encBuffer.reserve(encLength);

// Put the DER data in our vector
i2d_X509(cert, &encBuffer;[0]);

//oscar

> Jaime Viz�n Gonz�lez wrote:
> 
> Hi folks!
> 
> I need to convert a certificate in PEM format stored in char array to
> X509 certificate in DER format.
> I have tried to use BIO_f_base64() and PEM_read_bio_X509() to convert
> it but I haven�t got results.
> Could anyone tell me how I can do it?
> 
> Thanks.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to