PATCH//NOTES Open the interactive version
← All lessons
Foundations · Beginner · 5 min

Certificates & PKI

How your browser knows a site is real.

What it is

A certificate ties a public key to a name, like shop.example.com. A certificate authority (CA) checks that the requester controls the name, then signs the certificate. Your device trusts a short list of root CAs, built into the operating system or browser. Roots sign intermediate CAs, which sign site certificates, so your browser follows the chain up to a root it already trusts. To get a certificate, a server sends the CA a certificate signing request (CSR) holding its public key; the private key never leaves the server. If that key is stolen, the certificate is revoked: CAs publish revocation lists (CRLs) and can answer single questions over OCSP, though many browsers now get revocation data pushed to them by the browser maker instead. This whole system of CAs, certificates and trust is called PKI.

Real case · 2011

DigiNotar

Attackers broke into DigiNotar, a Dutch certificate authority, and issued themselves a valid certificate for google.com. It was used to intercept Gmail traffic, mostly from users in Iran. Browser makers removed DigiNotar from their trusted lists, which made every certificate it had issued worthless, and the company went bankrupt within weeks.

Source: Wikipedia: DigiNotar

How defenders stop it

  • Keep private keys on the server (or in a hardware security module) and never email them
  • Revoke and replace a certificate as soon as its key may be exposed
  • Automate renewal so certificates never expire unnoticed
  • Never click through a browser's certificate warning on a site you log in to

Try it yourself

Inspect a real site's certificate chain with SSL Labs

Check yourself

1. What does a certificate authority do when it signs a certificate?

  1. Encrypts the website's data for it
  2. Vouches that the public key in it belongs to that name
  3. Stores the website's private key
  4. Speeds up the connection
Show answer

Vouches that the public key in it belongs to that name. The CA checks the requester controls the name, then signs to say so. Your browser trusts that signature because it trusts the CA.

2. A server's private key is stolen. What should happen to its certificate?

  1. Nothing until it expires
  2. Renew it with the same key
  3. Revoke it and issue a new one with a new key pair
  4. Change the server's admin password
Show answer

Revoke it and issue a new one with a new key pair. Revocation tells clients to stop trusting it, and a new key pair makes the stolen key useless for the replacement.

3. Why did removing DigiNotar from browsers' trusted lists stop its rogue google.com certificate working?

  1. Browsers check every certificate's chain up to a trusted root
  2. Google changed its IP address
  3. The certificate was encrypted
  4. Gmail stopped using HTTPS
Show answer

Browsers check every certificate's chain up to a trusted root. No trusted root means no trusted chain, so every DigiNotar certificate failed the check.

Answer them in the app to earn XP.

Next: Linux command line →