Cheatsheet: OpenSSL
Last updated 2026-09-29
Private Keys
Generate a 2048-bit RSA private key
Generate an EC (elliptic curve) private key
Encrypt an existing private key with a passphrase
Extract the public key from a private key
CSRs & Certificates
Generate a CSR from an existing private key
Generate a key + CSR in one step
Create a self-signed certificate valid for 365 days
One-liner: self-signed key + cert together
Add Subject Alternative Names non-interactively
Inspecting & Verifying
Print full certificate details
Show just the validity dates / subject / issuer
Print CSR details
Verify a certificate against a CA bundle
Confirm a private key and certificate belong to the same pair (compare the hashes)
TLS Handshake Testing
Connect to a server and dump its certificate chain + negotiated TLS version
Show the entire chain the server presented, not just the leaf
Check just the remote certificate's expiry
Force a specific TLS version for the test connection
Format Conversions
Convert a certificate from PEM to DER (binary)
Convert a certificate from DER back to PEM
Bundle a key + certificate into a password-protected PKCS#12 file
Extract the private key and certificate back out of a PKCS#12 file