tips
34 tips Openssl
One command, setting or habit at a time about Openssl: what it does, the line to copy and a caveat or two.
Access and security 34
-
Sends a chosen host name in the TLS handshake so you see that site's certificate.
openssl s_client -connect 203.0.113.10:443 -servername example.com </dev/null | openssl x509 -noout -subject -
Re-signs an existing self-signed certificate with new dates, keeping its key and extensions.
openssl x509 -in cert.pem -days 365 -signkey key.pem -out cert-new.pem -
Computes an HMAC of a file or text with a secret key, as used for webhook signatures.
printf %s hello | openssl dgst -sha256 -hmac secret -
Loads the legacy provider so OpenSSL 3 can read a .pfx made with RC2 or 3DES.
openssl pkcs12 -legacy -in old.pfx -nokeys -
Encode and decode base64 with one command that works the same on Linux, macOS and BSD.
echo 'aGVsbG8gd29ybGQ=' | openssl base64 -d -
Write the TLS session secrets to a file so a packet capture of that connection can be decrypted.
| openssl s_client -connect example.com:443 -servername example.com -quiet -keylogfile keys.log -
Find the folder OpenSSL uses for openssl.cnf and trusted certificates on this machine.
openssl version -d -
Compare the public key inside a certificate with the one derived from a private key.
openssl x509 -in site.pem -noout -pubkey | openssl sha256 -
See exactly which cipher suites a config string like ECDHE+AESGCM allows.
openssl ciphers -v 'ECDHE+AESGCM' -
Turn a CSR into a certificate signed by a homelab CA, keeping the host names from the request.
openssl x509 -req -in nas.csr \ -
Grab every certificate a server presents, so you can inspect or verify the chain offline.
echo | openssl s_client -connect example.com:443 -servername example.com -showcerts 2>/dev/null \ -
Convert a .cer or .der certificate into the text PEM format Linux software expects.
openssl x509 -inform der -in cert.cer -out cert.pem -
Encrypt and decrypt a single file with a password the safer way openssl enc offers.
openssl enc -aes-256-cbc -pbkdf2 -salt -in notes.txt -out notes.txt.enc -
Prove a file came from you and was not changed, using a key pair and two commands.
openssl dgst -sha256 -sign private.pem -out backup.tar.gz.sig backup.tar.gz -
Generate a crypt style password hash for cloud-init, Ansible or a user account.
openssl passwd -6 -
Encrypt a private key file with a passphrase, or take it off for a service that cannot ask.
openssl pkey -in site.key -aes256 -out site-enc.key -
Inspect a certificate signing request and check its signature, so a typo does not cost a reissue.
openssl req -in site.csr -noout -text -verify -
See if a server sends a stapled OCSP response with its certificate, and what it says.
echo | openssl s_client -connect example.com:443 -servername example.com -status 2>/dev/null \ -
Decode the hex error codes that OpenSSL based programs print in logs.
openssl errstr 0A000086 -
Benchmark AES and other algorithms on a NAS, Pi or VPS before you pick a cipher or VPN.
openssl speed -evp aes-256-gcm -
See all certificates in a chain or CA bundle, since x509 only reads the first one.
openssl storeutl -noout -certs fullchain.pem -
Run a tiny TLS server to test a certificate, a client or a firewall rule.
openssl s_server -accept 8443 -cert cert.pem -key key.pem -www -
Make a CSR with several Subject Alternative Names in one line, without a config file.
openssl req -new -key site.key \ -
Check the protocol a server picks in the TLS handshake, such as h2 or http/1.1.
echo | openssl s_client -connect example.com:443 -servername example.com -alpn h2 2>/dev/null | grep -i alpn -
Split a PKCS#12 bundle from Windows or a NAS export into PEM files for Linux software.
openssl pkcs12 -in site.pfx -nokeys -clcerts -out cert.pem -
Make s_client fail on a wrong host name or untrusted chain instead of just printing a warning.
echo | openssl s_client -connect example.com:443 -servername example.com \ -
Generate any type of private key with the modern genpkey command instead of genrsa.
openssl genpkey -algorithm ed25519 -out ed.key -
Opens a STARTTLS session to a mail server and shows the certificate and TLS details.
openssl s_client -starttls smtp -connect mail.example.com:587 -servername mail.example.com -brief -
Combines a private key, certificate and chain into one password-protected .pfx file.
openssl pkcs12 -export -inkey site.key -in site.pem \ -
Checks whether a certificate and its intermediates form a valid chain before you deploy them.
openssl verify -show_chain -CAfile root.pem -untrusted intermediate.pem cert.pem -
Prints random bytes from a secure generator, encoded as base64 or hex, for use as a password or key.
openssl rand -base64 32 -
Creates a private key and a self-signed certificate with a subjectAltName, for testing HTTPS locally.
openssl req -x509 -newkey rsa:2048 -days 365 \ -
Prints the SHA-256 fingerprint of a PEM certificate, for comparing with a value you trust.
openssl x509 -fingerprint -sha256 -noout -in cert.pem -
Prints the start and end date of a website's TLS certificate from the terminal.
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -dates
Nothing in this filter yet.