PKI Foundations
Keys, certificates, certificate authorities, chains of trust and revocation — the ideas everything else builds on.
Public Key Infrastructure (PKI) is the set of people, policies and software that lets two strangers on a network decide whether to trust each other. Every padlock in your browser, every signed software update and every enterprise Wi-Fi login leans on it.
Hashes
Section titled “Hashes”A hash function turns any amount of data into a short, fixed-size fingerprint. SHA-256 always gives 256 bits, written as 64 hex characters. Two things make it useful:
- The same input always gives the same hash.
- You can’t work backwards from a hash, and you can’t find two inputs with the same hash.
Change one character and the hash changes completely. Signatures and certificate fingerprints are built on this.
Key pairs
Section titled “Key pairs”It starts with a key pair: a private key you keep secret and a public key you can hand to anyone. Data signed with the private key can be verified with the public key. Nobody can forge that signature without the private key.
Strictly, you don’t sign the data. You sign its hash. That’s why signing a 4 GB file is as fast as signing a tweet.
The three key types you’ll meet:
| Type | Notes |
|---|---|
| RSA | The oldest and most widely supported. Keys are large: 2048 bits or more. |
| ECDSA (P-256) | Elliptic-curve keys. Much smaller and faster for the same strength. step uses it by default. |
| Ed25519 | A newer elliptic-curve scheme. Common in SSH. X.509 support is still uneven. |
Try it: sign and verify
Section titled “Try it: sign and verify”You need the step CLI and OpenSSL from Lab Setup. Make a folder:
mkdir -p ~/pki-lab/foundations && cd ~/pki-lab/foundationsWrite a message and hash it:
echo "Meet at the usual place at 9." > message.txtshasum -a 256 message.txt7b9f06f5a39eae74b95b06181dbfbf9f1210fb3f756a45c38c54bc5af9bee9bb message.txtYour hash is the same as this one, because your input is the same.
Make a key pair. Choose a password to protect the private key:
step crypto keypair alice.pub alice.keyYour public key has been saved in alice.pub.Your private key has been saved in alice.key.Look at the public key. It’s safe to share:
cat alice.pub-----BEGIN PUBLIC KEY-----MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEfNJAO7q8L0Gn9Pv87tU62DN8pDu+vtHs7ppwqz9SkpPPlpH2AqyZqSS11Yf/6Oxg36joeIlafEXV4xDfcYwXsw==-----END PUBLIC KEY-----Yours is different. This text format is PEM: base64 data between BEGIN and END lines.
Sign the message with the private key. Enter the key password when OpenSSL asks:
openssl dgst -sha256 -sign alice.key -out message.sig message.txtVerify it with the public key:
openssl dgst -sha256 -verify alice.pub -signature message.sig message.txtVerified OKAnyone with alice.pub can run that check. Only the holder of alice.key could have made the signature.
Break it: change one character
Section titled “Break it: change one character”Change the 9 to an 8:
echo "Meet at the usual place at 8." > message.txtshasum -a 256 message.txtbe19a7ebd3b7dae617543e334c5f81d2050d6cad85ea117a167f1e9fd7992855 message.txtOne character changed, and the whole hash changed. Verify the old signature against the new message:
openssl dgst -sha256 -verify alice.pub -signature message.sig message.txtVerification failureThe signature still belongs to Alice. It just doesn’t match this message any more. That’s how a browser knows a certificate hasn’t been edited since the CA signed it.
Certificates
Section titled “Certificates”A public key on its own says nothing about who owns it. A certificate binds a public key to an identity — a hostname, a person, a device — and is signed by someone you already trust. The common format is X.509.
Subject— who the certificate is for.Subject Alternative Name (SAN)— the names it is actually valid for, likeapi.example.com.Issuer— the authority that signed it.Validity— not-before and not-after dates.Key Usage / Extended Key Usage— what it may be used for, such as server auth or client auth.
Certificate authorities and chains
Section titled “Certificate authorities and chains”A Certificate Authority (CA) signs certificates. Usually a long-lived root CA, kept offline, signs an intermediate CA. The intermediate signs everyday leaf certificates. A verifier walks the chain from the leaf up until it reaches a root it already trusts.
Where do roots come from? Your operating system and browser ship with a trust store of more than 100 public roots. A private PKI, like the one you’ll build, adds its own root to the machines that should trust it, and to nothing else.
When trust ends: expiry and revocation
Section titled “When trust ends: expiry and revocation”Certificates expire on purpose — short lifetimes limit the damage of a stolen key. When a key is compromised before then, the CA can revoke the certificate. It publishes that through a CRL (a list) or OCSP (a live lookup).
Go deeper
Section titled “Go deeper”- RFC 5280 — the X.509 certificate and CRL profile.
- RFC 6960 — OCSP.
- FIPS 180-4 — the SHA-2 hash family.
- RFC 6090 — fundamental elliptic-curve cryptography.
Check yourself
Tap a card to flip it. Nothing is scored or saved.
Progress is saved in this browser only.