How to convert certificate from .pem to .der format

2008-09-30 Thread praveens

I want to know the openssl APIs to convert a certificate from .pem to .der
format.
I know about the openssl command which does the same. But Can you tell me
how to do it in a Cprogram using openssl or any other method
-- 
View this message in context: 
http://www.nabble.com/How-to-convert-certificate-from-.pem-to-.der-format-tp19722997p19722997.html
Sent from the OpenSSL - User mailing list archive at Nabble.com.
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]


Re: How to convert certificate from .pem to .der format

2008-09-30 Thread delcour.pierre

praveens wrote:

I want to know the openssl APIs to convert a certificate from .pem to .der
format.
I know about the openssl command which does the same. But Can you tell me
how to do it in a Cprogram using openssl or any other method
  

Hi,

load your x509 file using

loaded = PEM_read_X509(f, NULL, NULL, NULL);   // load in pem
with f = fopen( fileName,rb);
and loaded a X509*

save it :
BIO *out=NULL;
   if ((out=BIO_new(BIO_s_file())) == NULL)
   return -1;
  
   if(BIO_write_filename(out, filename2) = 0)

   return -1;
   if (! i2d_X509_bio(out, loaded)) // save it in der.
   return -1;
   return 0; // success

filename is the file's name of pem certificate, filename2 is the file's 
name for der certificate.


(joke)You can also use syscall (/joke)
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]


Re: How to convert certificate from .pem to .der format

2008-09-30 Thread ugen


There is an apps directory in the openssl source tarball. That is a gud
starting point to dig for the api's ur looking for.

-ugen


praveens wrote:
 
 I want to know the openssl APIs to convert a certificate from .pem to .der
 format.
 I know about the openssl command which does the same. But Can you tell me
 how to do it in a Cprogram using openssl or any other method
 

-- 
View this message in context: 
http://www.nabble.com/How-to-convert-certificate-from-.pem-to-.der-format-tp19722997p19748370.html
Sent from the OpenSSL - User mailing list archive at Nabble.com.
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]