Skip to main content
Be Bitwise

Certificates & PKI

Cryptographic Protocols · Networking & Cryptography track

7 min read

In this module

Who Do You Trust?

When your browser connects to your bank's website, the TLS handshake proves the server holds a private key. But how do you know that private key actually belongs to your bank, and not an attacker? This is the authentication problem, and the answer is Public Key Infrastructure (PKI): a system of certificates, Certificate Authorities, and trust chains.

Digital Certificates

A digital certificate (X.509 certificate) binds a public key to an identity. It contains:

  • Subject: The identity (e.g., "www.example.com")
  • Public key: The subject's public key
  • Issuer: The Certificate Authority that signed the certificate
  • Validity period: Start and expiration dates
  • Signature: The CA's digital signature over all the above

The CA's signature is the load-bearing part. It says "I, the Certificate Authority, have verified that this public key belongs to this entity." Anyone who trusts the CA can trust this binding.

Certificate Authorities

A Certificate Authority (CA) is an organisation trusted to verify identities and issue certificates. When you request a certificate for your domain, the CA confirms you actually control the domain (via DNS records, email, or a file you place on the server), then signs your certificate.

Major CAs include DigiCert, Let's Encrypt, Sectigo, and GlobalSign. Your operating system and browser ship with a pre-installed list of trusted root CAs, typically 100-200 of them.

Key Concept

A Certificate Authority vouches for the binding between a public key and an identity by signing the certificate. Your browser trusts a set of root CAs, and any certificate chain that traces back to a trusted root is accepted. This hierarchical trust model makes it possible to verify the identity of any server on the internet.

Certificate Chains

Root CA certificates are too valuable to use directly. If a root key is compromised, all trust collapses. Instead, root CAs sign intermediate CA certificates, and intermediate CAs sign end-entity (server) certificates.

To verify a server certificate, your browser:

  1. Checks the server certificate's signature using the intermediate CA's public key
  2. Checks the intermediate CA certificate's signature using the root CA's public key
  3. Finds the root CA in its pre-installed trust store
  4. If the chain is valid and the root is trusted, the server's identity is confirmed

Certificate Validation

Beyond verifying signatures, the browser checks:

  • Domain match: The certificate's subject (or Subject Alternative Names) must match the domain you're connecting to
  • Expiration: The certificate must be within its validity period
  • Revocation: The certificate must not have been revoked (checked via CRL or OCSP; Let's Encrypt, for one, shut down its OCSP service in 2025 and now publishes CRLs only)
  • Key usage: The certificate must be authorised for the purpose it's being used for
  • Transparency: Chrome and Safari also require proof that the certificate was logged publicly (signed certificate timestamps, or SCTs, from Certificate Transparency logs), and reject it otherwise

Revocation checking has always been patchy in practice: browsers often skip live OCSP queries for speed and privacy, and Firefox and Chrome instead push compact revocation lists to their users. The industry's other answer is to make certificates expire sooner, so a stolen key stays useful for less time. Under a 2025 CA/Browser Forum ballot, the maximum lifetime of a public TLS certificate fell from 398 days to 200 in March 2026, drops to 100 days in March 2027 and reaches 47 days in March 2029.

What Can Go Wrong

CA compromise: If an attacker grabs a CA's private key, they can mint certificates for any domain on Earth. It's happened. DigiNotar was breached in 2011, and attackers issued fake certificates for Google, Yahoo, and other major sites.

Certificate misissuance: CAs sometimes issue certificates without proper validation. Certificate Transparency (CT) logs provide a public audit trail of every issued certificate, so domain owners can spot unauthorised ones.

Expired certificates: Forgetting to renew triggers those scary browser warning pages. Automated renewal tools like Let's Encrypt's certbot turn this into a non-issue.

Let's Encrypt and Automated Certificates

Let's Encrypt, launched in 2015, blew up the certificate landscape by giving away free, automated certificates. Using the ACME protocol, a server can prove domain ownership and receive a certificate in seconds without a human in the loop.

HTTPS adoption shot up across the web almost overnight. Before Let's Encrypt, obtaining a certificate meant manual processes and annual fees. Now the majority of web traffic is encrypted.

Certificate Pinning

Certificate pinning goes beyond standard PKI by hardcoding which certificate (or public key) a client expects for a specific server. Even if an attacker obtains a valid certificate from a different CA, the pinned client rejects it cold.

Mobile apps lean on pinning to defend against MITM attacks that might come from compromised or government-controlled CAs. The downside is that pinning makes certificate rotation hairy, and a mistake can lock your users out of the app entirely.

The Trust Problem

PKI works, but it asks you to trust hundreds of CAs. Any single one could, in theory, issue a certificate for any domain. That's a concentration of power that makes plenty of security researchers nervous. Certificate Transparency, DANE (DNS-based authentication), and alternative trust models try to chip away at the problem, though CA-based PKI is still the dominant system for web security.

Understanding Certificates in Practice

Knowing how certificates and PKI work is core knowledge for anyone touching networked systems. When a TLS connection fails with a certificate error, understanding the trust chain tells you whether you're looking at an expired certificate, a missing intermediate, a self-signed certificate, or a genuine man-in-the-middle attack. When deploying a service, you need to obtain and manage certificates correctly: choose the right CA, configure your server to present the full chain, and automate renewal so you don't wake up to an outage. Let's Encrypt and similar tools democratised certificate issuance, but the underlying PKI concepts still matter when something goes wrong.

Try it on four errors you're likely to meet. For each one, name the cause and the fix before opening the answer.

1. Chrome: NET::ERR_CERT_DATE_INVALID

The certificate is outside its validity period: almost always expired, occasionally not yet valid because the client's clock is wrong. Renew it, and automate renewal (certbot or any ACME client) so it doesn't happen again.

2. Chrome: NET::ERR_CERT_COMMON_NAME_INVALID when visiting api.example.com

Domain mismatch. The certificate's Subject Alternative Names don't include api.example.com, perhaps because it was issued only for example.com and www.example.com. Reissue it with the right name, or a wildcard such as *.example.com.

3. curl: SSL certificate problem: unable to get local issuer certificate, but the site opens fine in a browser

An incomplete chain. The server sends its own certificate but not the intermediate, and browsers paper over this by caching or fetching intermediates while curl doesn't. Configure the server to send the full chain (with certbot, that's fullchain.pem rather than cert.pem).

4. OpenSSL: self-signed certificate on an internal dashboard

The certificate's issuer is itself, so no trusted root vouches for it. For a real service, get one from a public CA, or from an internal CA whose root you install on every client. Clicking through the warning (or passing -k to curl) leaves you unable to tell this certificate apart from an attacker's.