Construct a memory BIO and write your cert to it. You can then read straight
out of this memory BIO into a buffer.
Summat like this:
/***************************************************************************
****
Function: get_certificate_as_buffer()
Input : const char* file - pointer to the name of the file
Output : nothing
Returns : const char* - pointer to the certificate buffer
****************************************************************************
***/
const char *
get_certificate_as_buffer(const char *file, char * data)
{
BIO *fbio = 0;
BIO *mbio = 0;
X509 *cert = 0;
if (file == 0 || data == 0 ) {
return NULL;
}
if ((fbio = BIO_new(BIO_s_file())) == 0) {
return NULL;
}
if ((mbio = BIO_new(BIO_s_mem())) == 0) {
BIO_free(fbio);
BIO_free(mbio);
return NULL;
}
if (BIO_read_filename(fbio, (char *) file) == 0) {
BIO_free(fbio);
BIO_free(mbio);
return NULL;
}
if (PEM_read_bio_X509(fbio, &cert, 0) == 0) {
BIO_free(fbio);
BIO_free(mbio);
return NULL;
}
if (PEM_write_bio_X509(mbio, cert) == 0) {
BIO_free(fbio);
BIO_free(mbio);
return NULL;
}
if(BIO_read(mbio, data, BIO_number_written(mbio))<=0) {
BIO_free(fbio);
BIO_free(mbio);
return NULL;
}
/*
can't remember if you use BIO_number_written() or assign a value from
the
call to PEM_write_bio_X509(mbio, cert). I seem to recall one of them
doesn't do what you'd expect
*/
BIO_free(fbio);
BIO_free(mbio);
X509_free(cert);
return data;
}
-----Original Message-----
From: Andrea e Luca Giacobazzi [SMTP:[EMAIL PROTECTED]]
Sent: Monday, May 10, 1999 5:24 PM
To: [EMAIL PROTECTED]
Subject:
Hi,
how can I convert a certificate from X509*xs structure format to DER
format,
and put it in a char * string in C, without using a temporary file ?
�
Thanks everibody in advance.
�
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]