Skip to main content
PKI, X.509 Certificates and TLS 1.3 Handshake
Lesson 10 of 19

PKI, X.509 Certificates and TLS 1.3 Handshake

Explain how PKI and X.509 v3 certificates bind public keys to identities, verify chains of trust and revocation, trace the TLS 1.3 1-RTT handshake, and select appropriate key storage and KDFs.

Intermediate 28 min Cryptography

Learning objectives

  • Compare centralized PKI, Web of Trust and TOFU trust models and explain the seven-stage key lifecycle
  • Inspect X.509 v3 certificate fields, CSR issuance workflows and ACME automation
  • Verify a certificate chain of trust and evaluate CRL, OCSP stapling and short-lived certificates
  • Trace the TLS 1.3 1-RTT handshake, forward secrecy and 0-RTT replay limitations
  • Select HSM, TPM or KMS key storage and choose between Argon2id, PBKDF2 and HKDF

Recommended first: Digital Signatures: RSA-PSS, ECDSA & Ed25519

#Why this matters

Strong digital signature algorithms such as Ed25519 or RSA-PSS guarantee that a signature mathematically matches a specific public key. Mathematics alone, however, cannot prove who actually owns that public key. If an active attacker intercepts a connection and hands you their own public key claiming it belongs to bank.example.test, every forged signature they produce will verify cleanly. Solving that binding between a public key and a real identity is an organizational trust problem, not a purely mathematical one.

Behind every certificate is a cryptographic key that passes through seven lifecycle stages: generation, distribution, storage, use, renewal, revocation and destruction. Each stage carries distinct failure modes, such as weak randomness during generation, man-in-the-middle substitution during distribution, plaintext leaks during storage, or delayed revocation after compromise. Public Key Infrastructure (PKI) and TLS 1.3 exist to manage these risks systematically at internet scale.

#Trust models: PKI, Web of Trust and TOFU

Security protocols organize key trust in three main ways. Centralized PKI relies on trusted third parties called Certificate Authorities (CAs) that verify identities and sign certificates; browsers ship with a curated root trust store so users can connect to unfamiliar websites without manual key exchange. Web of Trust (used in PGP and GPG) removes central authorities and lets peers sign one another's keys directly, which works well for small technical communities but struggles at global web scale. Trust On First Use (TOFU), used by SSH, accepts a server's public key on the first connection and warns loudly if that key ever changes later.

Trust Models in Practice
Centralized PKI (HTTPS)
  • Trusted CAs sign key bindings
  • Scales to billions of websites
  • CA compromise affects all users
Web of Trust (PGP)
  • Peers sign each other's keys
  • Decentralized, no single CA
  • Hard to bootstrap for newcomers
TOFU (SSH)
  • Client pins key on first visit
  • Zero setup, no CA needed
  • Vulnerable on first connection

For the public web, centralized PKI won because a user visiting a new site has no prior relationship with its operator. The trade-off is that every root CA in a device's trust store becomes a high-value trust anchor.

#X.509 v3 certificates, CSRs and ACME

An X.509 v3 certificate, specified in RFC 5280, binds a public key to an identity and is sealed by a CA's digital signature. Key fields include the version, unique serial number, signature algorithm, issuer (the signing CA), validity window (Not Before and Not After), subject, public key info and v3 extensions. Three extensions are critical during verification:

  • Subject Alternative Name (SAN): lists the exact DNS hostnames or IP addresses the certificate covers. Modern browsers check SAN rather than the legacy Subject Common Name (CN).
  • Key Usage / Extended Key Usage: restricts whether the key may sign certificates, authenticate a TLS server, or sign code.
  • Basic Constraints: states whether the certificate belongs to a CA (CA:TRUE) or a regular end-entity leaf (CA:FALSE).

When a server needs a certificate, it never sends its private key to the CA. Instead, the server generates a key pair locally, builds a Certificate Signing Request (CSR) containing its public key and subject information, and signs the CSR with its own private key to prove possession. A Registration Authority (RA) validates the applicant, and the CA signs the resulting X.509 certificate while the private key stays strictly on the server. Validation depth varies across Domain Validation (DV, automated proof of domain control), Organization Validation (OV, legal entity checks) and Extended Validation (EV, stricter auditing). Automated Certificate Management Environment (ACME), popularized by Let's Encrypt, automates DV challenges, issuance and renewal so administrators avoid manual errors.

#Chain of trust and certificate revocation

Root CAs keep their private keys offline in hardened facilities and sign Intermediate CAs, which in turn issue leaf certificates to servers. When a client connects, it validates the chain of trust upward from the leaf certificate to a trusted root.

  1. Leaf CertificateVerify CA signature, validity dates, SAN match and CA:FALSE
  2. Intermediate CAVerify root signature, validity and CA:TRUE Basic Constraints
  3. Root CAMatch against pre-installed OS or browser trust store
  4. DecisionAccept connection or abort on any failed check

Crucially, trust in the root CA does not come from mathematics; it comes from the root certificate being pre-installed in the operating system or browser trust store.

If a server's private key is stolen before its certificate expires, the CA must revoke it. Traditional revocation mechanisms have practical weaknesses. Certificate Revocation Lists (CRLs) are periodically published lists of revoked serial numbers, which grow large and lag behind real-time compromises. Online Certificate Status Protocol (OCSP) lets clients query the CA directly, but direct lookups reveal the user's browsing history to the CA and often soft-fail (accepting the certificate anyway) when the OCSP responder times out. OCSP stapling improves privacy and latency by having the web server fetch a fresh signed OCSP response from the CA and staple it into the TLS handshake. Because revocation still has gaps, the industry shifted toward short-lived certificates (typically 90 days or less) renewed automatically via ACME, limiting the exposure window of any compromised key.

#The TLS 1.3 1-RTT handshake and forward secrecy

TLS 1.3 (RFC 8446) simplified and hardened transport security by removing legacy primitives: static RSA key exchange, CBC-mode ciphers, RC4, 3DES and SHA-1 are gone. Every standard handshake uses ephemeral Elliptic Curve Diffie-Hellman (ECDHE) for key agreement and an AEAD cipher (such as AES-GCM or ChaCha20-Poly1305) for application data, completing in a single round trip (1-RTT).

TLS 1.3 1-RTT HandshakeTLS 1.3 1-RTT HandshakeClientServerClientHello (supported ciphers, ECDHE key_share)ServerHello (chosen cipher, ECDHE key_share)Both sides derive handshake keys via HKDF; messages below are encryptedEncryptedExtensions, Certificate, CertificateVerify, FinishedFinishedApplication data flows encrypted with AEAD traffic keys

After exchanging key_share values in ClientHello and ServerHello, both peers derive shared handshake keys using HKDF and encrypt the rest of the handshake. The server sends its X.509 Certificate, followed by CertificateVerify (a digital signature over the entire handshake transcript proving possession of the private key) and Finished (an HMAC over the transcript confirming integrity). Because the session keys come from freshly generated ephemeral ECDHE shares that are discarded afterward, TLS 1.3 guarantees forward secrecy: an attacker who records encrypted traffic today and steals the server's long-term private key six months later still cannot decrypt the recorded sessions. TLS 1.3 also defines an optional 0-RTT early-data mode for resumed sessions, but 0-RTT data is vulnerable to replay attacks and must only be enabled for strictly idempotent requests.

#Key storage and key derivation functions

Protecting long-term keys requires dedicated hardware or managed services rather than plain files on disk. Hardware Security Modules (HSMs) are tamper-resistant appliances that perform signing operations internally so private keys can never be exported. Trusted Platform Modules (TPMs) provide similar hardware-backed key binding on endpoints and servers. Cloud Key Management Services (KMS) wrap HSMs behind audited APIs and fine-grained access control.

When deriving keys, choosing the right Key Derivation Function (KDF) depends on input entropy:

Input type Recommended KDF Why
User passwords (low entropy) Argon2id or PBKDF2 Intentionally slow and memory-hard (Argon2id) to resist offline guessing
High-entropy shared secrets (ECDHE) HKDF (RFC 5869) Fast, cryptographically clean extract-and-expand step without wasted CPU

You can inspect a live server's TLS 1.3 handshake and X.509 fields using openssl against a lab host such as example.test:

Inspecting a lab TLS 1.3 certificate chain
$ openssl s_client -connect portal.example.test:443 -servername portal.example.test -tls1_3 </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer -dates -ext subjectAltName,basicConstraints
subject=CN = portal.example.test
issuer=CN = Example Lab Intermediate CA
notBefore=Oct  1 00:00:00 2026 GMT
notAfter=Dec 30 23:59:59 2026 GMT
X509v3 Subject Alternative Name:
    DNS:portal.example.test, DNS:api.example.test
X509v3 Basic Constraints: critical
    CA:FALSE

#Defending and common mistakes

  • Committing private keys to repositories: storing .key or .pem files in Git exposes server identity immediately. Store keys in an HSM, TPM or KMS and enforce secret scanning in CI.
  • Disabling TLS verification in client code: flags such as verify=False or InsecureSkipVerify: true turn HTTPS into unauthenticated encryption vulnerable to trivial man-in-the-middle attacks.
  • Omitting intermediate certificates: servers that send only the leaf certificate cause validation failures on clients that do not cache intermediates. Always serve the full leaf-plus-intermediate chain.
  • Misusing KDFs: running HKDF directly on user passwords allows rapid offline brute force, while running Argon2id on every TLS handshake wastes CPU. Match the KDF to input entropy.
  • Enabling 0-RTT on state-changing routes: never allow TLS 1.3 0-RTT early data on endpoints that transfer funds, create orders or mutate state, because captured early data can be replayed.

#Summary

  • PKI and X.509 v3 certificates (RFC 5280) solve the organizational trust problem by having CAs sign the binding between a public key and an identity while private keys stay on the server via CSRs.
  • Clients verify the chain of trust from leaf through intermediate CA to a root CA pre-installed in the device trust store, checking signatures, dates, SAN entries and Basic Constraints.
  • OCSP stapling and automated short-lived (90-day) ACME certificates mitigate the lag, privacy leaks and soft-fail weaknesses of CRLs and direct OCSP checks.
  • TLS 1.3 completes in 1-RTT using ephemeral ECDHE (key_share), HKDF-encrypted handshake messages (CertificateVerify and Finished), and AEAD traffic ciphers, delivering mandatory forward secrecy.
  • Store long-term keys in HSMs, TPMs or KMS, use Argon2id or PBKDF2 for password-derived keys, and use HKDF for high-entropy shared secrets.

Lecture presentations

Slides on this topic: view them in the browser or download the PDF.

Key management and PKI

X.509 certificates · Chain of trust · TLS 1.3 handshake

Slides: 26 PDF · 905 KB

Knowledge check

Sign in to take the test, complete lessons and save your progress. Log in

Practice: test your knowledge