You should use some thing like this:
 
FILE * file = NULL;
X509 * cert = NULL;

// Open the DER file
file = fopen("der_file_name", "rb");
// load it into a X509 object
cert = d2i_X509_fp(file, NULL);
fclose(file);
file = fopen("pem_file_name", "w");
//write the X509 object to a PEM file
int PEM_write_X509(file, cert);
fclose(file);
X509_free(cert);
 
You would also need to check for errors.
 
Joe


On 4/3/06, Oscar So <[EMAIL PROTECTED]> wrote:
>
> Hi,
>  
> How do I convert x509 der to x509 pem using OpenSSL API ?
>  
> And, for which would be similar to the following:
> "openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER " but in a
> way pragmatically.
>  
> Thanks,
> Oscar
>  
 

Reply via email to