Hello, I currently have a short program that converts a certificate from pem format to der format.
static int vpncm_convert_pem_to_der(struct cm_module *module, char *pem_file_name, char *der_file_name ) { int res,ret = 0; FILE* f; BIO *out = NULL; X509 *loaded = NULL; f = fopen( pem_file_name,"r"); if(f != NULL) { /*Read the cert into structure*/ loaded = PEM_read_X509(f, NULL, NULL, NULL); if(loaded) { /*write from the internal X509 to pemfile*/ out = BIO_new(BIO_s_file()); if(out != NULL) { /*der_file_name is the file's name for der certificate*/ if(BIO_write_filename(out, der_file_name) > 0) { /*Convert the pem structure to der and save it in der file.*/ res = i2d_X509_bio(out, loaded); } fclose(f); BIO_free_all(out); } return ret; } I would like to do the same, i.e. convert from pem to der, for a private key file. The key may have been generated either with ecdsa or rsa 2048/4096 algorithm. May I use the program above and just replace a few openssl api's, or is it more complicated? Can someone share a piece of code that does the job? Thanks -- View this message in context: http://openssl.6102.n7.nabble.com/Program-to-convert-private-key-from-pem-to-der-format-tp52282.html Sent from the OpenSSL - User mailing list archive at Nabble.com. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org