Skip to content

Instantly share code, notes, and snippets.

@aranair
Last active October 24, 2016 07:27
Show Gist options
  • Save aranair/9bea2cdcd0969aa4e2b9 to your computer and use it in GitHub Desktop.
Save aranair/9bea2cdcd0969aa4e2b9 to your computer and use it in GitHub Desktop.
Openssl Stuff
Convert a DER file (.crt .cer .der) to PEM
openssl x509 -inform der -in certificate.cer -out certificate.pem
Convert a PEM file to DER
openssl x509 -outform der -in certificate.pem -out certificate.der
Convert a PKCS#12 file (.pfx .p12) containing a private key and certificates to PEM
openssl pkcs12 -in keyStore.pfx -out keyStore.pem -nodes
You can add -nocerts to only output the private key or add -nokeys to only output the certificates.
Convert a PEM certificate file and a private key to PKCS#12 (.pfx .p12)
openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt
Convert a PEM from pkcs#1 format to pkcs#8 format
openssl pkcs8 -topk8 -inform PEM -outform PEM -in infile.pem -out outfile.pem -nocrypt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment