Most commonly used openSSL commands

From Stuff!
Jump to: navigation, search

Generating

Generate a new private key and Certificate Signing Request (CSR)

openssl req -out CSR.csr -new -newkey rsa:2048 -nodes -keyout private.key

Generate a self-signed certificate

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout private.key -out certificate.crt

Generate a certificate signing request for an existing private key

openssl req -new -out CSR.csr -key private.key

Generate a certificate signing request based on an existing certificate

openssl x509 -x509toreq -in certificate.crt -out CSR.csr -signkey private.key

Remove a passphrase from a private key

openssl rsa -in privateKey.pem -out newPrivateKey.pem


Checking

Check a Certificate Signing Request - CSR

openssl req -text -noout -in CSR.csr

or

openssl req -text -noout -verify -in CSR.csr

Check a private key

openssl rsa -in private.key -check

Check a certificate

openssl x509 -in certificate.crt -text -noout

Check a PKCS#12 file (.pfx or .p12)

openssl pkcs12 -info -in keyStore.p12