Linux & shell: TLS & certificates (openssl)
8 Linux & shell commands: TLS & certificates (openssl). Click a command to see what each part does.
Linux & shell: TLS & certificates (openssl)Index
- Whole sheet251
- Navigate & list13
- Create, copy, move, delete13
- View & compare files9
- Permissions & ownership31
- Help & shell basics11
- Users & groups6
- Install packages7
- Package & software versions29
- System info9
- Network basics & SSH10
- Zip & compress4
- Shell operators6
- Processes6
- Files & search8
- Text processing pipelines4
- Disk3
- Network5
- Services & logs6
- Archives & copying4
- Firewall7
- Scheduling: cron & systemd timers6
- Storage, mounts & LVM10
- Kernel, hardware & limits8
- Performance & tracing10
- TLS & certificates8
- Packet capture & network debugging10
- Terminal tools8
TLS & certificates (openssl)8
openssl s_client -connect <host>:443 -servername <host> -showcerts </dev/nullShow a server's certificate and chainWhat each part does
s_client -connect <host>:443open a TLS connection-servername <host>send SNI, so you get the right certificate on shared IPs-showcertsprint every certificate the server sends</dev/nullclose the connection right after the handshake
openssl s_client -connect <host>:443 -servername <host> </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer -datesWhen does a site's certificate expire?What each part does
openssl s_client ...fetch the certificate| openssl x509 -nooutparse it without printing the encoded certificate-subject -issuer -dateswho it is for, who signed it, notBefore and notAfter
openssl x509 -in <cert>.pem -noout -textRead a certificate fileWhat each part does
x509 -in <cert>.pema PEM certificate file-noout -textfull details: subject, SANs (DNS names), validity, key size
openssl x509 -noout -pubkey -in <cert>.pem | sha256sum; openssl pkey -pubout -in <key>.pem | sha256sumDoes this key belong to this certificate?What each part does
x509 -pubkeypublic key from the certificatepkey -puboutpublic key derived from the private keysha256sumthe two hashes must be identical
openssl req -new -newkey rsa:2048 -nodes -keyout <name>.key -out <name>.csr -subj "/CN=<domain>"Create a private key and a CSRWhat each part does
req -newnew certificate signing request-newkey rsa:2048 -nodesgenerate a 2048-bit key, not encrypted with a passphrase-keyout / -outwhere to write the key and the CSR-subj "/CN=<domain>"subject; add -addext "subjectAltName=DNS:<domain>" for SANs
openssl req -x509 -newkey rsa:2048 -nodes -days 365 -keyout <name>.key -out <name>.crt -subj "/CN=<domain>"Self-signed certificate for testingWhat each part does
req -x509output a self-signed certificate instead of a CSR-days 365valid for a year
openssl verify -CAfile <ca-bundle>.pem <cert>.pemCheck a certificate against a CA bundleWhat each part does
openssl verifyOK if the chain validates; otherwise the reason (expired, unable to get issuer)-CAfiletrusted CA and intermediates
openssl s_client -connect <host>:443 -tls1_2 </dev/null; openssl s_client -connect <host>:443 -tls1_3 </dev/nullWhich TLS versions does a server accept?What each part does
-tls1_2 / -tls1_3force one protocol version; a handshake failure means it's not supported
Nothing matches.
My DevOps Playbook by Angelo John Calleja