Cryptography › Module 2 › Lesson 3
Public Key Infrastructure (PKI)
Certificates, trust chains, and how PKI connects identities to public keys
Opening
Anyone can run genrsa and claim to be your bank. PKI is the answer to “who says this public key is really that name?”
Last lesson you published a padlock. A padlock is not a nameplate. A phishing kit can generate a perfect 4096-bit key pair in one second and title the window “Your Bank.” RSA did not fail. Identity failed. Public Key Infrastructure (PKI) is the boring machinery that binds a name — a DNS name, an email, an organization — to a public key, for a limited time, using a signature from someone your software already trusts. That someone is a Certificate Authority (CA) in the usual web story. Your OS and browser ship a list of trust anchors (root CAs). A website presents a certificate: “this public key belongs to this name, until this date, signed by this issuer.” The issuer’s cert is signed by another, until the chain hits a root you already trust. “I generated a key” is a lab step. It is not identity. Module 3 goes deep on CAs, issuance, and lab certs. This lesson is the map: cert, chain, anchor, name matching — notes in $HOME/cyberlium-lab, a toy self-signed you will distrust on purpose, no attacks on real CAs or sites.
1. A certificate is a signed document: name + public key + dates + issuer
Strip the PDF mystique. An X.509 certificate is structured data: a subject (the name being claimed), a public key, a validity window (notBefore / notAfter), an issuer, and a signature over that data. The signature is not encryption of your traffic. It is the issuer’s private key saying “I attest this binding.” Anyone with the issuer’s public key can verify that signature — which is lesson 4’s mechanism, used here as glue. If the signature verifies and the name matches what you intended to reach, you will use the subject’s public key to continue (in TLS, to authenticate the handshake).
What a certificate is not: a secret. Certificates are copied, logged, stapled into handshakes, pasted into tickets. The secret is the matching private key, held by the subject (the site, the VPN appliance, the code-signing laptop). Stealing the .crt without the private key does not let you impersonate the name. Stealing the private key does — until revocation and expiry catch up, imperfectly. This module does not teach you to steal keys. It teaches you to stop treating a green lock as “the company is moral” and start treating it as “this public key is bound to this name by a chain I trust.”
Four nouns on the cert. Miss one and people click through warnings as if they were ads.
Subject
The name (CN / SAN). A valid cert for evil-bank.example is valid for evil-bank.example — not for your bank.
Public key
The padlock from lesson 2, now labeled. Encrypt-to-owner and handshake auth aim here, not at a random genrsa.
Validity
Clocks matter. Expired certs fail closed for a reason. “Just this once” is how outages and phishing mix.
Issuer signature
A CA (or a self-signature) over the fields. Self-signed means the subject vouches for itself — not a trust anchor.
2. Chains walk to a trust anchor: server cert → intermediate(s) → root you already have
Browsers do not ship every website’s public key. They ship a comparatively small set of root CA certificates — trust anchors. A typical HTTPS cert is signed by an intermediate CA, whose cert is signed by a root. Verification walks that chain: check signatures, check validity windows, check that intermediates are allowed to issue, check that the name in the leaf matches the host you typed. If any step fails, you get a warning. The warning is the product working. Clicking through because a helpdesk script said so is how people install malware with a smile.
Trust is not transitive friendship. Trusting a root means you accept certificates that root (and its authorized intermediates) issue, within policy. A compromised or mis-issuing CA is a sector-wide incident — that is why Module 3 spends time on CAs, and why real PKI includes revocation (CRL / OCSP), Certificate Transparency logs, and name constraints. You do not need those protocols memorized today. You need the picture: your trust starts at an anchor you did not generate this afternoon in cyberlium-lab. A chain that ends at a self-signed toy is a chain that ends at you talking to yourself.
3. Why “I generated a key” is not identity — and why self-signed labs teach distrust
openssl genrsa succeeded. openssl req -x509 can even wrap that key in a self-signed certificate that says CN=paypal.com if you type that string. The file will look like a certificate. OpenSSL will not call the police. Your browser, facing the real PayPal, will not replace the WebPKI chain with your toy. If you force a client to trust your toy as a root, you have built a private PKI — powerful on a lab VM you own, dangerous if you sneak that root onto other people’s machines. This course does not sneak roots. The lab self-signed exists so you can read the fields and then delete it, saying out loud: subject string ≠ identity unless a trust anchor you already had signed the binding.
Phishing uses the gap: a cert can be valid for login-paypal.example while the padlock is honest about a dishonest name. Read SAN/CN and the issuer. You will not intercept other people’s HTTPS or mint lookalike certs. Module 3’s CA lessons are issuance on hosts you own — not a forgery kit for the public web.
4. Preview of Module 3: Certificate Authorities, issuance, and why browsers look bored
A CA’s job is identity vetting plus signing. Automated issuance (ACME / Let’s Encrypt-class) proved domain control with HTTP or DNS challenges — still not “the company is good,” still “they proved they control this name for now.” Extended Validation marketing is less of a user-interface religion than it was; name matching and chain validity remain. Lab CAs in Module 3 are for hosts you own. They are not a license to mint certificates for domains you do not control. Forgery of public-web certificates is an attack. This lesson stops at literacy so signatures (next) make the issuer’s pen feel mechanical rather than magical.
5. Wrong vs right: trusting a genrsa selfie vs reading a chain to an anchor
Worked failure — treating any .crt as a personality, or building a rogue root for the cafe Wi-Fi.
Wrong
Tell users a self-signed toy that claims CN=their-bank is “the same as HTTPS.” Install a random root CA from a forum. Click through name-mismatch warnings to finish a lab against a live bank. Scrape other people’s certificates to “forge” identities. Attack a public CA. Commit a private key next to a cert that names a domain you do not own. PKI literacy is not a forgery course.
Right
In $HOME/cyberlium-lab, write what a cert binds (name, public key, dates, issuer). Optionally mint a 1-day self-signed TOY that claims a fictional CN, dump the fields, and note that nobody else should trust it. Record chain → anchor. chmod 600 notes; delete toy keys. Next — Digital Signatures — is the pen the CA used. Module 3 — CAs in depth.
6. Practical: PKI notes plus an optional self-signed TOY you will not trust as a bank
The required artifact is pki-lab-notes.txt you authored. The optional openssl req -x509 block exists to make “self-signed is not a trust anchor” tactile. Use a fictional CN. One day of validity. Delete the key. Do not add this cert to a browser trust store. Do not aim it at a real domain. Do not intercept anyone’s traffic.
Command guide
DEFENSIVE PKI lab — notes + optional 1-day self-signed TOY in cyberlium-lab
DEFENSIVE. Literacy on YOUR machine. NEVER install this as a public root. NEVER claim a domain you do not own. NEVER intercept others' HTTPS. NEVER attack CAs or forge certificates for the public web.
Command — copy this
mkdir -p "$HOME/cyberlium-lab" cd "$HOME/cyberlium-lab"
Command — copy this
{
echo "=== PKI LAB NOTES (no private keys) ==="
echo "cert_binds: subject name + public key + validity + issuer signature"
echo "secret: the subject's private key — the .crt is not the secret"
echo "chain: leaf -> intermediate(s) -> trust anchor (root already on the OS/browser)"
echo "identity: openssl genrsa is NOT identity; anyone can generate a pair"
echo "name_match: valid cert for evil-bank.example != your bank"
echo "self_signed: subject signs itself — fine on a lab VM YOU own, not WebPKI"
echo "module_3_preview: CAs, issuance, lab certs on hosts you control"
echo "ethics: no rogue roots on other people, no public-web forgery, no site attacks"
} > pki-lab-notes.txt
chmod 600 pki-lab-notes.txt 2>/dev/null || trueOPTIONAL tactile demo — fictional CN, 1 day, DELETE the key after you read fields:
Command — copy this
openssl req -x509 -newkey rsa:2048 -keyout toy-pki-key.pem -out toy-pki-cert.pem \ -days 1 -nodes -subj "/CN=not-really-a-bank.example"
Command — copy this
openssl x509 -in toy-pki-cert.pem -noout -subject -issuer -dates -fingerprint
Optional command
Subject == issuer on a self-signed toy. That is the lesson: it vouches for itself.
Command — copy this
chmod 600 toy-pki-key.pem toy-pki-cert.pem 2>/dev/null || true rm -f toy-pki-key.pem
Keep the cert a few minutes to stare at, then: rm -f toy-pki-cert.pem
NEVER: copy toy-pki-cert.pem into another user's trust store NEVER: -subj "/CN=paypal.com" as a trick against a human NEVER: openssl as a MITM kit on cafe Wi-Fi
Mission: pki-lab-notes.txt (and optional self-signed you distrust)
1) In $HOME/cyberlium-lab, write pki-lab-notes.txt: cert binds name to public key; chain to a trust anchor; genrsa ≠ identity; name matching; Module 3 CA preview. 2) Optional: 1-day self-signed toy with a fictional CN; dump subject/issuer/dates; delete the private key; do not trust it as a bank. 3) chmod 600 notes. Never install a rogue root on others. Never forge public-web certs. Never attack CAs or sites.
Stuck? Ask Cyberlium AI Mentor
If “the padlock means the site is safe” or “my genrsa cert should convince a browser I am a bank” still blurs, ask for a hint — not a forgery kit. Try: "Hint only: what fields a certificate binds, why the chain must end at a trust anchor I already had, and why a self-signed toy in cyberlium-lab is not identity?" You still write the notes. No MITM. No public-web fake certs.
You now separate keys from names: a certificate is a signed binding, a chain is a walk to an anchor, and a key you generated this hour is not PayPal. Module 3 will put CAs in the chair. Next — Digital Signatures — is the issuer’s pen in slow motion: hash the bytes, sign with a private key, verify with a public key. Authenticity and integrity, not confidentiality. Optional openssl dgst -sign on a file YOU own. No forging signatures as an attack.
Knowledge Check
APPLY: A pop-up says “certificate error” on a bank URL. A friend generated a self-signed cert with CN=that-bank and wants you to install it as a trusted root “so PKI class has a happy padlock.” What does PKI bind, and what do you refuse?
Multiple choice
Knowledge Check
APPLY: You dump a leaf certificate: subject accounts.example, issuer Intermediate-CA, then a root already in the OS store. What did the chain do, and which mistake stays closed?
Multiple choice
Knowledge Check
APPLY: True or False: openssl genrsa plus openssl req -x509 proving you can type CN=paypal.com means browsers should trust you as PayPal, and that is the ethical way to “test PKI” on cafe Wi-Fi.
True or False