openssl x509 -inform der -in certificate.cer -out certificate.pem
openssl x509 -outform der -in certificate.pem -out certificate.der
You can add -nocerts
to only output the private key or add -nokeys to only output the certificates.
openssl pkcs12 -in keyStore.pfx -out keyStore.pem -nodes
openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt
PKCS#1 format has the following header:
-----BEGIN RSA PRIVATE KEY-`----
while PKCS#8 has:
-----BEGIN PRIVATE KEY-----
To convert it, run:
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in pkcs1.key -out pkcs8.key