Cryptography › Module 3 › Lesson 4
Lab — Analyze SSL Certificate
Inspect a live HTTPS certificate with openssl and curl copy-paste commands
Opening
Lab: read a live public certificate like an analyst — example.com or a domain YOU own, then lock cert-lab.txt.
The last three lessons gave you a handshake map, field names, and CA rules. This lab is the hands on the same object: a public HTTPS certificate. openssl s_client completes a TLS client handshake and prints the PEM. openssl x509 prints subject, issuer, dates, and SANs. curl -vI shows that HTTPS actually answered. You will copy subject, issuer, and validity dates into $HOME/cyberlium-lab/cert-lab.txt and chmod 600. Allowed targets: example.com (the documentation host this course names) or a domain YOU own or are authorized to operate. Reading a public certificate is the same fetch a browser already does. Forbidden: MITM, fake CAs, intercepting other people’s traffic, pointing openssl at a random company’s internal hostname, installing the PEM into a trust store, and saving anyone’s private key. Next is Quiz — TLS/HTTPS, then Module 4 crypto hygiene.
1. What the commands actually do: client handshake, then parse the leaf — not a scan kit, not interception
openssl s_client -connect HOST:443 -servername HOST opens TCP 443 and runs TLS, sending SNI so virtual hosts present the correct certificate. The PEM between BEGIN CERTIFICATE and END CERTIFICATE is the leaf (s_client may also show the chain). Piping to openssl x509 -noout -subject -issuer -dates -ext subjectAltName prints the fields you already named. curl -vI --connect-timeout 10 https://HOST asks for headers over TLS; verbose mode shows the handshake at a high level and the HTTP status. Neither command decrypts other people’s sessions. Neither command plants a CA. On Windows, use Git Bash or WSL if openssl and curl are not in PowerShell. If s_client waits after the PEM, end the client (Ctrl+C) or feed it a closed stdin (echo | …) as in the script. -servername is not optional on modern multi-site hosts: without SNI you may get a default cert that does not match the name you intended — a useful lesson, not a reason to skip SNI. Write the name you typed, then the SAN list, then yes/no match.
cert-lab.txt is evidence of YOUR read: subject, issuer, notBefore, notAfter, SAN, protocol if you saw it, and the ethics line. It is not a password file, not a cookie jar, not a private key. chmod 600 anyway because the folder will hold lab passphrases in the next module. Empty notes fail. Notes that include a classmate’s captured traffic fail ethics even if openssl ran. Challenge (optional): repeat on a domain you own and compare issuer and validity period with example.com — still public certs, still your notes, still no MITM.
2. Scope: public certs you may fetch. Out: fake CAs, café proxies, other people’s sessions
example.com is explicitly in this lab’s contract. A hostname whose DNS you control is in contract. A bank you do not operate, a school VPN appliance you saw on a sticker, and a neighbor’s router admin page are not “more realistic labs.” Visiting a public website in a browser is ordinary. Silently intercepting that visit for someone else is not. Installing the PEM you saved as a trusted root is the CA lesson’s failure mode — do not undo it here because “the lab wanted a file.” The file is cert-lab.txt, mode 600, text fields, your words.
3. Wrong vs right: intercepting a classmate vs openssl+curl on example.com and locked cert-lab.txt
Worked failure — same openssl binary, opposite target and leftover files. Right is a public leaf and four written fields.
Wrong
mitmproxy on café Wi-Fi. Fake CA on a family tablet. openssl against an internal hostname you are not allowed to test. certutil -addstore the lab PEM. Paste live cookies or a PRIVATE KEY into cert-lab.txt. Call the lab done because curl returned 200 with no fields written. Skip chmod on a shared PC.
Right
openssl s_client + x509 and curl -vI to example.com or a domain YOU own. Write subject, issuer, dates (and SAN) to $HOME/cyberlium-lab/cert-lab.txt. chmod 600. No fake CA. No interception. Next: Quiz — TLS/HTTPS.
4. Hands-on: copy-paste openssl and curl, fill cert-lab.txt, lock it
Create the lab directory. Run the dump. Fill every placeholder in cert-lab.txt in your own handwriting-in-a-file — do not submit an empty template. Then chmod 600. If openssl is missing, install it from a vendor you trust or use WSL; do not “substitute” a TLS-intercepting app store VPN.
Command guide
Inspect a public HTTPS cert — example.com or YOUR domain, then cert-lab.txt
DEFENSIVE public-cert lab. example.com OR a domain YOU own. NEVER MITM. NEVER install a fake CA. NEVER intercept others.
Command — copy this
mkdir -p "$HOME/cyberlium-lab" cd "$HOME/cyberlium-lab" HOST="example.com" # or a domain YOU own
Command — copy this
echo | openssl s_client -connect "${HOST}:443" -servername "$HOST" 2>/dev/null \
| openssl x509 -noout -subject -issuer -dates -ext subjectAltNameCommand — copy this
echo | openssl s_client -connect "${HOST}:443" -servername "$HOST" 2>/dev/null \
| openssl x509 -outform PEM > "$HOME/cyberlium-lab/cert-lab-leaf.pem"Command — copy this
curl -vI --connect-timeout 10 "https://${HOST}" 2>&1 | head -n 40Windows PowerShell (if openssl/curl exist): still only example.com or YOUR domain.
Optional command
curl.exe -vI --connect-timeout 10 https://example.com
Command guide
cert-lab.txt then chmod 600 — subject, issuer, dates, no secrets
Command — copy this
NOTES="$HOME/cyberlium-lab/cert-lab.txt"
{
echo "=== SSL CERTIFICATE LAB ==="
echo "target: example.com OR a domain I own (public cert read)"
echo "host_typed:"
echo "subject:"
echo "issuer:"
echo "notBefore:"
echo "notAfter:"
echo "SAN:"
echo "name_match: yes/no"
echo "curl_https: (status / TLS observed — not cookies, not passwords)"
echo "ethics: public cert only; no MITM; no fake CA; no intercepting others; no private keys"
} > "$NOTES"Fill the fields from openssl output (edit the file — empty placeholders fail the mission).
Command — copy this
chmod 600 "$NOTES" "$HOME/cyberlium-lab/cert-lab-leaf.pem" 2>/dev/null || chmod 600 "$NOTES"
Windows without chmod: WSL/Git Bash, or restrict the files in your profile.
NEVER: openssl s_client to a host you may not visit NEVER: mitmproxy / sslstrip / addstore NEVER: paste session cookies or PRIVATE KEY blocks into cert-lab.txt
Mission: cert-lab.txt with subject, issuer, dates (mode 600)
Run openssl (s_client + x509) and curl against example.com or a domain YOU own. Write subject, issuer, and validity dates (plus SAN/name-match) to $HOME/cyberlium-lab/cert-lab.txt. chmod 600 the notes and any saved PEM. This is a public certificate read — not MITM, not a fake CA, not intercepting others, not a private key dump.
Stuck? Ask Cyberlium AI Mentor
If “I need a proxy to see a real cert” still feels true, ask for a hint — not mitmproxy. Try: "Hint only: how does openssl s_client plus x509 print subject/issuer/dates on example.com, why -servername matters, and why installing the PEM as a CA is out of scope?" You still fill cert-lab.txt. No fake roots. No intercepting others. No live cookies.
You fetched a public leaf the way a client does, wrote the fields an analyst actually records, and locked the file. Matching SAN to the name you typed is the handshake’s name-binding check in slow motion. Next — Quiz — TLS/HTTPS — ten APPLY items on the handshake, certificates, CAs, and this lab. Then Common Crypto Mistakes in Module 4. Still no homebrew attacks, still no MITM.
Knowledge Check
APPLY: openssl x509 -noout -dates printed notBefore and notAfter for example.com. A classmate wants to add the PEM to the system root store “so the lab is more complete” and to rerun the commands through mitmproxy on the café. What did you measure, and what is forbidden?
Multiple choice
Knowledge Check
APPLY: True or False: You should only run these openssl/curl probes against hosts you are allowed to test (example.com or a domain you own), and reading that public certificate authorizes intercepting other people on the same Wi-Fi.
True or False
Knowledge Check
APPLY: curl -vI https://example.com shows TLS and an HTTP status. What belongs in cert-lab.txt, and what must never go there?
Multiple choice