OpenSSL Convert SSL Certficates between CER, PEM, and PKS.

Mindwatering Incorporated

Author: Tripp W Black

Created: 10/21/2014 at 03:59 PM

 

Category:
Linux
Configuration

Issue:
Need to convert CER certificates to PEM format and back.

Solution of CER to PEM:
# openssl x509 -outform der -in mycertificate.cer -out mycertificate.der
# openssl x509 -inform der -in mycertificate.der -out myfinalcertificate.pem

Solution of PKS#12 ( .pfx .p12) to PEM w/private key
# openssl pkcs12 -in mykeyring.pfx -out myfinalcertificate.pem -nodes


Separate a PFX certificate w/a password protected private key into its parts:
a. Export the private key:
# openssl pkcs12 -in sourcecertificate.pfx -nocerts -out domainapp_privatekey.pem -nodes
<enter password>

b. Export the certificate:
# openssl pkcs12 -in sourcecertificate.pfx -nokeys -out domainapp_cert.pem

c. Remove the passpphrase from the private key:
Note: This will remove the password protection.
# openssl rsa -in domainapp_privatekey.pem -out domainapp_privatekey.key



previous page

×