Skip to content

Open SSL cheatsheet

Generate

Generate self-signed certificate

openssl req -new -x509 -keyout cert.pem -out server.pem -days 365 -nodes

Generate self-signed certificate in PFX format

openssl genrsa 2048 > private.pem
openssl req -x509 -new -key private.pem -out public.pem
openssl pkcs12 -export -in public.pem -inkey private.pem -out mycert.pfx

Convert

Convert .cer certificate to .p12

openssl x509 -in cert.cer -inform DER -out cert.pem -outform PEM
openssl pkcs12 -export -out cert.p12 -inkey cert.key -in cert.pem

Convert certificate from PEM to PFX format

openssl pkcs12 -export -out certificate.pfx -inkey privkey.pem -in cert.pem -certfile chain.pem