openssl is the Swiss-army knife for certificates, keys, and TLS debugging. The command surface is large; this card covers the 20 % of commands that handle 80 % of real tasks: key generation, self-signed certs, reading existing certs, live server testing, and format conversion. For SSH key management patterns, see ssh-config.
Generate keys
Prefer Ed25519 for SSH; RSA 4096 or ECDSA P-256 for TLS.
Command
Key type
Notes
openssl genrsa -out key.pem 4096
RSA 4096
Widely supported; larger than needed for modern TLS.
openssl x509 -text output uses Subject Alternative Name for the hostnames browsers check. The Common Name field is ignored by all modern browsers; put the hostname in the SAN extension.
Self-signed certs without a SAN cause Chrome and Firefox to reject them even on localhost. Always include -addext "subjectAltName=DNS:localhost".
openssl s_client exits after the handshake unless you send data. Pipe echo Q | or printf "HEAD / HTTP/1.0\r\n\r\n" | to get the full output.
Key and certificate pairing: openssl x509 -noout -modulus -in cert.pem | md5sum and openssl rsa -noout -modulus -in key.pem | md5sum must match. Mismatches cause nginx/Apache to refuse to start.
openssl pkcs12 -export without -legacy fails on OpenSSL 3 when importing into older Java or Windows tools. Add -legacy for compatibility with old importers.
Default days for CSR signing is 30 in some openssl builds. Always set -days explicitly.