Certificates Cheat Sheet
1. Scan hosts for certificates
1.1 Find ports with certificates (Task 1)
nmap -p- -sV --script ssl-cert <host> # ALL ports, detect TLS on odd ports [V: -sV helps find TLS on unexpected ports]
nmap -sV --script ssl-cert -p 443,8443 <host>
nmap -p- -T4 <host> -oN ports.txt # fast pass first, then -sV on open ports
tcpwrapped= connection closed right after the handshake (TCP wrapper/filter), not probed for TLS. Retry with-sVoropenssl s_client -connect host:port[R].- In the nmap output,
ssl/httpmeans HTTPS, plainhttpmeans no TLS. Only list ports that really present a certificate.
1.2 nmap NSE scripts for TLS [V]
| Script | Purpose |
|---|---|
ssl-cert | Dump certificate: subject, issuer, validity, key, SANs |
ssl-enum-ciphers | Protocols + cipher suites with grade A-F (based on the SSL Labs rating guide). Intrusive/noisy. Does not test SSLv2. |
sslv2 | Check SSLv2 support |
ssl-dh-params | Weak Diffie-Hellman groups (Logjam) |
ssl-heartbleed | Heartbleed |
ssl-poodle | POODLE (SSLv3 CBC) |
ssl-ccs-injection | CCS injection |
nmap -sV --script ssl-cert,ssl-enum-ciphers,ssl-dh-params -p 443 <host>
nmap -sV --script "ssl-*,sslv2" -p 443 <host>
1.3 sslscan [R] (check sslscan --help for your version)
sslscan <host>:443 # protocols, ciphers, cert, DH size, compression, renegotiation
sslscan --show-certificate <host>:443
sslscan --ssl2 --ssl3 --tls10 --tls11 <host> # per-version flags (also --tls12 / --tls13)
sslscan --no-colour <host>:443 > sslscan.txt # clean text for the report
sslscan --starttls-smtp <host>:25
Reading the output: Accepted = enabled on the server, Preferred = chosen first. Look at: protocol list, cipher list (weak ones), DHE xxxx bits, certificate block, TLS compression, heartbleed.
1.4 testssl.sh and openssl s_client [R]
testssl.sh <host>:443 # full check; -p protocols, -E ciphers per protocol, -U vulnerabilities
openssl s_client -connect <host>:443 -servername <host> -showcerts </dev/null
openssl s_client -connect <host>:443 -servername <host> </dev/null 2>/dev/null | openssl x509 -noout -text
openssl s_client -connect <host>:443 -tls1_1 # test one protocol (modern builds may refuse old ones locally)
openssl s_client -connect <host>:443 -cipher 'ECDHE-RSA-AES256-GCM-SHA384' # test one TLS1.2 cipher
openssl s_client -connect <host>:443 -ciphersuites TLS_AES_256_GCM_SHA384 # TLS1.3 suites use -ciphersuites
openssl s_client -connect <host>:25 -starttls smtp
2. Protocols & cipher suites
2.1 Secure / modern (keep)
| Item | Status |
|---|---|
| TLS 1.3 | Best. All suites have forward secrecy (PFS) by design |
| TLS 1.2 | OK if limited to ECDHE + AEAD (GCM / ChaCha20) |
TLS 1.3 suites: TLS_AES_256_GCM_SHA384, TLS_AES_128_GCM_SHA256, TLS_CHACHA20_POLY1305_SHA256
TLS 1.2 suites (OpenSSL names):
ECDHE-ECDSA-AES256-GCM-SHA384 ECDHE-RSA-AES256-GCM-SHA384
ECDHE-ECDSA-AES128-GCM-SHA256 ECDHE-RSA-AES128-GCM-SHA256
ECDHE-ECDSA-CHACHA20-POLY1305 ECDHE-RSA-CHACHA20-POLY1305
How to read a suite: ECDHE = key exchange (gives PFS) · RSA/ECDSA = authentication (cert key type) · AES256-GCM = bulk cipher + AEAD mode · SHA384 = hash (PRF/handshake).
2.2 Legacy: can/should be disabled
| Item | Why |
|---|---|
| TLS 1.0 / TLS 1.1 | Deprecated by RFC 8996 (2021), CBC-only/SHA-1 era [R] |
CBC suites (...-CBC-SHA, ...-CBC-SHA256/384) | Padding/timing attacks (Lucky13, BEAST on TLS 1.0) [R] |
Static RSA key exchange (TLS_RSA_WITH_..., AES256-SHA) | No forward secrecy: a leaked server key decrypts recorded traffic; ROBOT [R] |
| DHE with 1024-bit group | Weak DH, Logjam. Need >= 2048 bit or use ECDHE [R] |
| SHA-1 MAC / signatures | Collision attacks, deprecated [R] |
Not weak, just not preferred: Camellia/ARIA ciphers. ECDHE-ARIA...-GCM is an AEAD suite with PFS, so don’t list it as weak. Disable for simplicity/compatibility, not security.
2.3 Weak / compromised: must be disabled
| Item | Problem |
|---|---|
| SSLv2 | Broken, DROWN [R] |
| SSLv3 | POODLE (RFC 7568 prohibits it) [R] |
| NULL ciphers | No encryption |
| aNULL / anon DH | No authentication, MITM trivial |
| EXPORT ciphers | 40/56-bit, FREAK/Logjam |
| DES, 3DES | 56-bit / 64-bit block, Sweet32 |
| RC4 | Biased keystream |
| RC2, IDEA, SEED | Obsolete/weak or 64-bit block |
| MD5 (MAC or cert signature) | Broken |
| TLS compression | CRIME |
| Insecure renegotiation | Injection attacks |
2.4 Known attack quick map [R]
| Name | Hits |
|---|---|
| POODLE | SSLv3 CBC |
| BEAST | TLS 1.0 CBC |
| CRIME / BREACH | TLS compression / HTTP compression |
| Heartbleed | OpenSSL 1.0.1 - 1.0.1f (software bug, not a protocol flaw) |
| Sweet32 | 64-bit block ciphers (3DES) |
| Logjam | Export/weak (1024-bit) DH |
| FREAK | Export RSA |
| DROWN | SSLv2 |
| ROBOT | RSA key exchange (PKCS#1 v1.5 oracle) |
| Lucky13 | CBC timing |
2.5 Hardening measures
- Disable SSLv2/SSLv3 (and TLS 1.0/1.1).
- Enable TLS 1.3, keep TLS 1.2 only with ECDHE + AES-GCM/ChaCha20.
- Remove CBC, static-RSA, RC4/3DES/IDEA, DHE-1024 suites (PFS: “TLS 1.3, or TLS 1.2 with ECDHE and non-PFS suites removed”).
- Other valid ones: fix SAN/CN mismatch, replace SHA-1/short-key cert, add HSTS, disable compression.
3. Certificate validation: what to check
3.1 Commands
openssl x509 -in cert.pem -noout -subject -issuer -serial -dates -fingerprint -sha256
openssl x509 -in cert.pem -noout -text | grep -E "Signature Algorithm|Public-Key|Not (Before|After)"
openssl x509 -in cert.pem -noout -ext subjectAltName,basicConstraints,keyUsage,extendedKeyUsage
openssl x509 -in cert.pem -noout -ext crlDistributionPoints,authorityInfoAccess
openssl x509 -in cert.pem -noout -checkend 0 # exit 1 = already expired
openssl verify -show_chain -CAfile root.pem -untrusted intermediate.pem cert.pem
# split a bundle (chain.pem) into c1.pem, c2.pem, ...
awk 'BEGIN{n=0} /BEGIN/{n++} {print > "c" n ".pem"}' chain.pem
3.2 Checklist
| Check | Insecure / fail when |
|---|---|
| Validity dates | Expired (notAfter in the past), not yet valid (notBefore in the future), or lifetime longer than allowed |
| Max lifetime (public TLS) | [V] 398 d until 14 Mar 2026 · 200 d from 15 Mar 2026 · 100 d from 15 Mar 2027 · 47 d from 15 Mar 2029. Private CAs are not bound but should follow |
| Self-signed | Issuer == Subject and not a trusted root (error 18, or 19 in chain) |
| Issuer / chain | Unknown/untrusted CA, missing intermediate, wrong chain order |
| Signature algorithm | Insecure: MD5, SHA-1 [R]. OK: SHA-256 / SHA-384 / SHA-512 (RSA, ECDSA) |
| Public key | Insecure: RSA < 2048 (1024 ~ 80-bit), ECC < 256 [R]. OK: RSA 2048 / 3072 / 4096, ECDSA P-256 / P-384 |
| Name match | Hostname not in SAN (CN is legacy; SAN is what counts), or SAN/CN mismatch |
| Key usage / EKU | Leaf lacks serverAuth; leaf has CA:TRUE; CA lacks keyCertSign |
| Revocation info | No CRL (CDP) and no OCSP (AIA) present, or status = revoked |
| Revocation status | Cert or any CA in the chain is revoked, or CRL expired / unreachable (unknown, not “good”) |
3.3 Workflow
- Read the scope. Task 3 asked for certificate validity. Cipher suites and protocol versions in the CSV are a different topic and don’t count.
- State your assumed scan date when judging “expired” and the CSV has no date.
- Sort by expiry date: certificates sharing a date with one you flagged are probably flagged too (one was missed this way).
- Self-signed is a separate finding, name it.
- Report must name the selected port, give exactly 3 measures, show command + output, and give an explicit verdict in one sentence.
4. CRL revocation check
4.1 Manual steps [R]
openssl x509 -in cert.pem -noout -ext crlDistributionPoints # find CRL URL
curl -o crl.der http://<crl-url>.crl
openssl crl -inform DER -in crl.der -out crl.pem # drop -inform DER if the CRL is PEM
openssl crl -in crl.pem -noout -lastupdate -nextupdate -issuer # CRL must not be expired
openssl verify -crl_check -CAfile issuer.pem -CRLfile crl.pem cert.pem
openssl verify -crl_check_all -CAfile chain-ca.pem -CRLfile crls.pem cert.pem # whole chain, needs a CRL per CA
-crl_check, -crl_check_all, -CRLfile, -partial_chain, -attime, -no_check_time and -crl_download all exist in openssl verify [V].
4.2 The script [T]
Tested on OpenSSL 3.0.13 against a local test CA: good cert returned OK, revoked cert returned error 23 ... certificate revoked, cert without CRL URL printed a message and exited. Not tested on a real multi-level chain.
#!/usr/bin/env bash
# usage: ./crl_checker cert.pem issuer.pem
url=$(openssl x509 -in "$1" -noout -ext crlDistributionPoints 2>/dev/null | grep -o 'http[^ ]*' | head -n1)
[ -z "$url" ] && { echo "no CRL distribution point in $1"; exit 2; }
curl -s -o /tmp/crl.der "$url"
openssl crl -inform DER -in /tmp/crl.der -out /tmp/crl.pem
openssl verify -crl_check -partial_chain -CAfile "$2" -CRLfile /tmp/crl.pem "$1"
-crl_checkis what makes verify actually look at the CRL. Without it you get a falseOK.-partial_chainlets an intermediate act as trust anchor, which avoidsunable to get issuer certificatewhen you only pass the direct issuer.- Needs the issuer as 2nd argument. CRL assumed DER. If
curlgets a 404 (CRL gone),openssl crlfails: report “CRL not retrievable = status unknown”.
4.3 Check the whole chain: each certificate against its own issuer
./crl_checker cert.pem intermediate_ca2.pem # end entity <- issuing CA's CRL
./crl_checker intermediate_ca2.pem intermediate_ca1.pem # intermediate 2 <- intermediate 1's CRL
./crl_checker intermediate_ca1.pem root_ca.pem # intermediate 1 <- root's CRL
# root_ca.pem: self-signed, usually has no CDP -> nothing to check, say so in the report
4.4 Common results [R]
| Output | Meaning |
|---|---|
cert.pem: OK | Not on the CRL (and chain valid) |
error 23 ... certificate revoked | Serial is on the CRL |
error 12 ... CRL has expired | CRL nextUpdate passed: result untrustworthy |
error 3 ... unable to get certificate CRL | No CRL for that issuer was supplied |
error 10 ... certificate has expired | Cert is expired. verify stops at the first error, so this can hide a revocation result |
error 18 / 19 | Self-signed cert / self-signed in chain |
error 20 ... unable to get local issuer certificate | Issuer missing: pass the right -CAfile or use -partial_chain |
Expired cert hiding the revocation result: check revocation at a time when the cert was valid, or skip the time check. Both options exist [V], behaviour combined with -crl_check untested here:
openssl verify -no_check_time -crl_check -partial_chain -CAfile issuer.pem -CRLfile crl.pem cert.pem
openssl verify -attime <epoch> -crl_check -partial_chain -CAfile issuer.pem -CRLfile crl.pem cert.pem
4.5 Writing the verdict (one sentence, with the reason)
“The end-entity certificate is not valid: its issuing CA is revoked (error 23 in the root’s CRL) and the certificate itself expired on
. Its own revocation status is unknown because the issuing CA’s CRL returned 404.”
Chain rule: if any CA in the chain is revoked or expired, everything below it cannot be trusted, even if the end-entity’s own CRL says “good”.
Sources
- OpenSSL
verifymanual: https://docs.openssl.org/3.5/man1/openssl-verify/ - nmap
ssl-enum-ciphers: https://nmap.org/nsedoc/scripts/ssl-enum-ciphers.html - SANS ISC, nmap TLS scripts (
sslv2,ssl-cert,ssl-dh-params): https://isc.sans.edu/diary.html?date=2020-05-07 - Certificate lifetime schedule (CA/B Forum ballot SC-081v3): https://sslinsights.com/200-day-ssl-certificate-validity/ and https://odown.com/blog/how-long-can-an-ssl-certificate-last-now/