SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
  • SSL/TLS
  • Encryption at Rest
  • Secrets Management
  • Password Management
  • RBAC
  • SAML
  • OWASP Top 10 and Common Attacks
  • DDoS Attacks and Defenses
  • Web Application Firewall (WAF)
  • Certificates and PKI
  • Multi-Factor Authentication (MFA)
  • Zero Trust
  • Key Management (KMS)
  • Data Privacy and GDPR Basics
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Operations and Security/Advanced Security

Certificates and PKI

How a chain of trusted authorities lets you believe a public key really belongs to who it says.

โฑ 14 min readAdvancedInterview FavouriteHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

PKI (public key infrastructure) is the system that lets you trust a public key. A certificate says "this key belongs to this name", and a certificate authority (CA) signs it. Your device already trusts a small set of root CAs, and trust flows down a chain from them.

  • A key alone proves nothing. Anyone can make a key and claim to be your bank. The signature from a trusted CA is what makes it believable.
  • A client checks the chain, the signatures, the dates, the name and whether the certificate was revoked.
  • Most outages in this area are boring: a certificate expired because renewal was manual.

02Concept: What is it?

The SSL/TLS page explains the handshake. This page is about the trust behind it. With public-key cryptography, you can sign with a private key and anyone can check it with the matching public key. The hard question is: whose public key is this? If an attacker swaps in their own, everything breaks.

PKI answers this with certificates. A certificate is a small signed file that holds a public key and says who owns it. The signer is a CA that you already trust. Because you cannot ship every site's key to every device, CAs form a chain: a root CA signs an intermediate CA, which signs the leaf certificate for a website.

The chain of trust
๐Ÿ›๏ธRoot CAin your trust store
โ†’โ†“signs
๐ŸขIntermediate CAdoes the daily signing
โ†’โ†“signs
๐Ÿ“„Leaf certificateshop.example.com
Your device trusts the root. Each link vouches for the next one down.
๐Ÿง Why intermediates?
Root keys are kept offline in a vault, because losing one would be a disaster. Intermediates do the everyday signing. If one leaks, only its branch has to be revoked.

03Real-Life Example

๐ŸตThe Passport Office
A border officer does not know you. They trust your passport because a government they recognise issued it, with a photo, a name, an expiry date and a stamp that is hard to forge. If the passport is expired, has someone else's name, comes from an unknown country, or is on a lost-and-stolen list, you are stopped. A certificate works the same way, and the browser is the border officer.
Passport
Certificate
The passport
The certificate
The issuing government
The CA
Governments the officer recognises
The trust store of root CAs
Name and photo
Subject name and public key
Expiry date
Not-after date
The official stamp
The CA's digital signature
The lost-and-stolen list
CRL or OCSP revocation

04Why Do We Need It?

๐ŸชชKnow who you talk to
Encryption to the wrong party is useless. PKI ties a key to a real name.
๐Ÿ•ต๏ธStop man-in-the-middle
An attacker cannot present a valid certificate for your site without the CA being fooled.
๐Ÿ“ˆScales to billions of sites
Trust a few hundred roots instead of sharing keys with every site.
๐ŸคService identity
Services inside a company use private CAs and certificates to prove who they are (mTLS).
โœ๏ธSigning
The same system signs code, documents and emails.
๐Ÿ”Replaceable trust
Revocation and short lifetimes let you cancel a bad key without changing every device.
PKI turns the question "is this key really theirs?" into a chain of signatures you can check in milliseconds.

05Where Do We Use It?

๐Ÿ”’HTTPS websites
Every secure website presents a certificate from a public CA.
๐Ÿ”mTLS between services
A private CA issues short-lived certificates to each service. See mTLS and Request Signing.
๐Ÿ“ฑMobile and IoT devices
Device certificates prove a device is genuine when it connects.
๐Ÿ“งEmail and documents
S/MIME and document signing use certificates to prove the sender or author.
๐Ÿ’ปCode signing
Operating systems check the signature on installers and updates.
๐Ÿ”ŒVPNs and Wi-Fi
Corporate VPNs and network access often use certificates instead of passwords.

06Types / Parts / How It Works

What is inside a certificate (X.509)

FieldWhat it holdsWhy it matters
SubjectWho the certificate is forThe identity being vouched for
Subject Alternative Names (SAN)The host names it is valid forBrowsers check the address against this list
Public keyThe key that belongs to the subjectUsed in the TLS handshake
IssuerThe CA that signed itTells the client which certificate to check next
Validity (not before, not after)The dates it can be usedLimits the damage from a stolen key
Key usageWhat the key may be used forA server key cannot act as a CA
SignatureThe CA's signature over all the aboveProves nothing was changed

What a client checks

  1. Chain. The leaf links through intermediates to a root in the trust store.
  2. Signatures. Each certificate was really signed by the one above it.
  3. Dates. Now is inside every certificate's validity period.
  4. Name. The address you typed is in the SAN list.
  5. Revocation. The CA has not cancelled it.

Ways to check revocation

MethodHow it worksWeak point
CRL (revocation list)Download a list of cancelled serial numbersLists grow large and go stale
OCSPAsk the CA about one certificateExtra delay, privacy leak, and clients often fail open
OCSP staplingThe server attaches a fresh, signed answerServer must fetch and refresh it
Short-lived certificatesValid for days, so revocation matters lessNeeds full automation
Public and private CAs
Public CA
๐ŸŒTrusted by browserswebsites on the internet
๐Ÿค–ACME automationfree, 90-day style certs
Private CA
๐ŸขTrusted inside a companyyou add the root yourself
๐Ÿ”Service mesh identityhours-long certs
Same technology, different trust store.
Public Private
VisualizerCheck a certificate chainPick a scenario (valid, expired, wrong hostname, untrusted root, revoked) and press โ€œRun next checkโ€. See which of the five checks fails first and what the browser does.
Visiting https://shop.example.com. Which certificate does the server present?
๐Ÿ›๏ธ
Root CA
Example Root CA (trusted)
๐Ÿข
Intermediate CA
signed by the root
๐Ÿ“„
Leaf certificate
names: shop.example.com
valid: 1 Oct 2026 to 30 Dec 2026
The server sends the leaf and the intermediate. The root is already in your device. Check date used in this demo: 4 Dec 2026.
  1. โณ1. Chain leads to a trusted rootnot run yet
    Follow the signatures: leaf, then intermediate, then a root that is in the browser trust store.
  2. โณ2. Each signature is validnot run yet
    Check that every certificate was really signed by the one above it, using that issuer's public key.
  3. โณ3. Dates are validnot run yet
    Today must be after notBefore and before notAfter for every certificate in the chain.
  4. โณ4. Name matches the sitenot run yet
    The address you typed (shop.example.com) must appear in the certificate's Subject Alternative Names.
  5. โณ5. Not revokednot run yet
    Ask the CA (OCSP, or a stapled answer, or a CRL) whether the certificate was cancelled early.
Checks run
0 / 5
Result
pending
Press โ€œRun next checkโ€ to walk through what a browser does in the first milliseconds of a secure connection. The first failed check stops everything.

A simplified order. Real clients also check key usage, the chain length and certificate transparency proofs, and they may run some checks in parallel.

07How to Use It / Steps / Implementation

Running certificates without outages

  1. 1
    Automate issuing and renewal
    Use ACME (the protocol behind Let's Encrypt) or your cloud's certificate manager. Manual renewal means an outage someday.
  2. 2
    Keep an inventory
    Know every certificate, where it runs and when it expires. Scan your domains for ones you forgot.
  3. 3
    Alert early on expiry
    Alert at 30, 14 and 7 days. Test that the alert reaches a person.
  4. 4
    Use short lifetimes
    Shorter validity means less damage from a stolen key and less reliance on revocation.
  5. 5
    Protect private keys
    Generate on the server or in a key service, never email them, and keep root keys offline. See Key Management (KMS).
  6. 6
    Run a private CA for internal traffic
    Issue short-lived service certificates, and distribute the root to your own machines only.
  7. 7
    Serve the full chain
    Send the leaf and the intermediates. A missing intermediate causes errors on some clients only, which is hard to debug.
  8. 8
    Turn on OCSP stapling and monitor Certificate Transparency
    Stapling speeds checks. Transparency logs show if anyone obtained a certificate for your domain.
๐Ÿ’กCertificate Transparency
Public CAs must publish what they issue to open logs. You can watch them for unexpected certificates for your domain, which is an early sign of a mis-issuance or attack.
โš ๏ธPinning is risky
Pinning means your app only accepts one specific key or CA. It blocks some attacks, but a rotation you forgot to plan can lock every user out. Prefer short-lived certificates and monitoring unless you can update clients quickly.

08Key Terms to Know

TermMeaning in easy words
PKIPublic key infrastructure: the people, rules and software that manage certificates
CertificateA signed file that links a public key to a name
CACertificate authority: a body that signs certificates
Root CAA top-level CA that is trusted directly by devices
Intermediate CAA CA signed by the root, used for everyday issuing
Leaf certificateThe certificate for one site or service
Trust storeThe list of root CAs a device or browser trusts
SANSubject Alternative Name: the host names a certificate is valid for
CRL / OCSPTwo ways to ask whether a certificate was revoked
OCSP staplingThe server attaches a fresh revocation answer to the handshake
ACMEA protocol that automates certificate issue and renewal
Certificate TransparencyPublic logs of all certificates that CAs issue
Self-signedA certificate signed by its own key, trusted only if you add it manually
PinningAccepting only a specific key or CA for a connection

09Pros, Cons and Trade-offs

โœ… Pros
  • Lets strangers verify each other with no prior contact
  • Scales through chains of trust
  • Standard, supported everywhere
  • Automation makes it cheap to run
  • Revocation and short lives limit damage
โš ๏ธ Cons
  • Trust depends on CAs being careful
  • Expiry causes frequent outages
  • Revocation checking is weak in practice
  • Private key theft is serious
  • Complex to run a private CA well

Trade-offs

ChoiceWe gainWe lose
Short-lived certificatesLess need for revocation, less damageRequires solid automation
Long-lived certificatesFewer renewalsBigger window if the key leaks
Public CATrusted by all browsersCost or rate limits, public names
Private CAFull control, internal namesYou run and secure it
PinningBlocks mis-issued certificatesRisk of lockouts
Wildcard certificateOne certificate for many namesOne leak exposes all of them

10Common Problems and Mistakes

Common mistakes

  1. Manual renewal. Someone leaves, the reminder goes to their old inbox, and the site goes down.
  2. Forgotten certificates. Internal tools and old test hosts expire quietly.
  3. Missing intermediate. Works on your laptop, fails on some phones.
  4. Disabling verification. A flag such as โ€œskip TLS checkโ€ in a client turns off the entire protection.
  5. One wildcard everywhere. A leak on a small test host exposes production.
  6. Keys in code or chat. Private keys must stay in a key store.
  7. Trusting a self-signed certificate by default. Add the specific certificate or CA, not โ€œtrust everythingโ€.

Things to watch

โฐClock drift
A device with the wrong date will see valid certificates as expired or not yet valid.
๐Ÿ”‘Compromised CA
A CA that signs wrongly can fool clients. Certificate Transparency and removal from trust stores are the response.
๐ŸขRevocation lag
Clients may not check revocation, or may ignore failures. Do not rely on it alone.
๐ŸงฎRate limits
Public CAs limit how many certificates you can request. Plan for it in big fleets.

11Real-World Examples

๐Ÿ†“Let's Encrypt
A free public CA that issues short-lived certificates using ACME. It made HTTPS the default across the web.
๐Ÿ“œCertificate Transparency
Public logs that make it hard for a CA to issue a certificate in secret. Browsers can require it.
๐ŸงฐService meshes
Meshes such as Istio and Linkerd issue short-lived certificates to each workload for mTLS.
โ˜๏ธCloud certificate managers
Cloud providers issue and renew certificates for load balancers automatically.
๐ŸšจExpiry outages
Many well-known services have gone down because a certificate expired. It is one of the most common avoidable outages.
โš ๏ธDigiNotar (2011)
A Dutch CA was breached and fake certificates were issued for major sites. Browsers removed its trust, and it went out of business.
Mini case: the expiring internal certificate
๐Ÿ“…Cert expires in 30 daysalert fires
โ†’โ†“ACME renews
๐Ÿ”„New cert deployedno restart needed
โ†’โ†“old one expires
โœ…Nobody noticesthat is the goal
Automation turns a surprise outage into a non-event.

12Related Topics to Read Next

SSL/TLSโ†’

The handshake that uses these certificates.

mTLS and Request Signing (HMAC)โ†’

Both sides present certificates, usually from a private CA.

Key Management (KMS)โ†’

Where private keys and CA keys should live.

Secrets Managementโ†’

Hand certificates and keys to services safely.

Zero Trustโ†’

Certificates give each service and device an identity to check.

Encryption at Restโ†’

The other place keys and trust matter.

Clock Synchronization Problemโ†’

Why a wrong clock breaks certificate checks.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • โœ”Certificate: a CA-signed file linking a public key to a name.
  • โœ”Chain: root CA, intermediate CA, leaf. Your device trusts the root.
  • โœ”Checks: chain, signatures, dates, name (SAN), revocation.
  • โœ”Revocation: CRL, OCSP, stapling, or short-lived certificates.
  • โœ”Automate: ACME for renewal, inventory, and expiry alerts.
  • โœ”Private CA: for internal services and mTLS.
  • โœ”Keep safe: private keys in a KMS, roots offline.
  • โœ”One line: โ€œA certificate is a passport for a key, and the browser is the border officer.โ€
โ† Previous
Web Application Firewall (WAF)
Next โ†’
Multi-Factor Authentication (MFA)