Skip to content

Instantly share code, notes, and snippets.

@anthavio
Created December 5, 2014 11:36
Show Gist options
  • Save anthavio/77997d5c4aff211e98c8 to your computer and use it in GitHub Desktop.
Save anthavio/77997d5c4aff211e98c8 to your computer and use it in GitHub Desktop.
openssl conversions
# id_dsa is openssh private key
openssl dsa -in id_dsa -outform pem > id_dsa.pem
openssl dsa -in id_dsa -outform der > id_dsa.cer
openssl dsa -in id_dsa.pem -pubout > id_dsa.pub.pem
openssl dsa -in id_dsa -pubout -outform der > id_dsa.pub.cer
# DER file (.crt .cer .der) to PEM
openssl x509 -inform der -in certificate.cer -out certificate.pem
openssl dsa
# PEM file to DER
openssl dsa -outform der -in id_dsa.pub.pem -out id_dsa.pub.der
openssl req -new -x509 -key id_dsa.pem -out id_dsa_cert.pem
# 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.
# PEM certificate file and a private key to PKCS#12 (.pfx .p12)
openssl pkcs12 -export -out id_dsa.pfx -inkey id_dsa.cer -in id_dsa.pub.cer -certfile CACert.crt
openssl pkcs12 -export -in pem-certificate-and-key-file -out pkcs-12-certificate-and-key-file
openssl pkcs12 -export -in pem-certificate-file -inkey pem-key-file -out pkcs-12-certificate-and-key-file
openssl pkcs12 -export -in pem-certificate-file -nokeys -nodes -out pkcs-12-certificate-file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment