Pcornel
Linux · Certificates & TLS

OpenSSL

Cheat sheet · https://pcornel.dk/topic.php?topic=2867

Back to the Topic

Answer

OpenSSL is the toolkit for keys, CSRs, certificates and TLS testing: openssl x509, req, pkey, verify, s_client.

Remember

Know the format: PEM (text, BEGIN lines) or DER (binary); PKCS#12 (.pfx) bundles key and chain. Convert with openssl x509 -inform der, openssl pkcs12. Always use -servername with s_client for SNI.

First checks

  • openssl x509 -in <cert> -noout -subject -issuer -dates -ext subjectAltName — certificate details
  • openssl s_client -connect <host>:443 -servername <name> </dev/null — live chain and verification
  • openssl verify -CAfile <ca> -untrusted <chain> <cert> — chain validation
  • trust list | head / ls /etc/ssl/certs — system trust store

Commands

openssl x509 -in cert.pem -noout -text
openssl req -in req.csr -noout -text -verify
openssl pkey -in key.pem -noout -text
openssl x509 -noout -pubkey
openssl pkey -pubout
openssl x509 -in cert.pem -outform DER -out cert.der
openssl verify -CAfile root.pem -untrusted inter.pem leaf.pem
openssl s_client -connect host:443 -servername host -showcerts
openssl s_client -connect host:443 -tls1_2
openssl s_client -connect mail:25 -starttls smtp

Verify in this order

file or server → openssl subcommand → decoded or tested → result

Where it usually breaks

First mismatch in identity/group resolution → Unix mode/ACL/capability → mount/sandbox constraint → SELinux/AppArmor policy → credential/TLS trust → protected operation; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2867

Confirmation

Confirm action

Continue?