> Andrea e Luca Giacobazzi wrote:
> 
> 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.
> 

You can use a memory BIO but the easiest way is to directly use the ASN1
functions.

Something like this will do it:

unsigned char *buf, *p;
int len;

len = i2d_X509(xs, NULL);
buf = Malloc(len);
p = buf;
i2d_X509(xs, &p);

... DER encoded cert in 'buf' ...

You need the temporary pointer 'p' because the ASN1 functions
automatically increment the passed pointer.

Steve.
-- 
Dr Stephen N. Henson.   http://www.drh-consultancy.demon.co.uk/
Personal Email: [EMAIL PROTECTED] 
Senior crypto engineer, Celo Communications: http://www.celocom.com/
Core developer of the   OpenSSL project: http://www.openssl.org/
Business Email: [EMAIL PROTECTED] PGP key: via homepage.


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

Reply via email to