Beginner Cryptography

Digital Certificates and PKI

A digital certificate is an electronic document that binds a public key to an identity. PKI (Public Key Infrastructure) is the system that manages the issuance, validation, and revocation of these certificates.

X.509 Certificate Structure

Version: 3
Serial Number: 0A:BC:12:...
Signature Algorithm: sha256WithRSAEncryption
Issuer: CN=Let's Encrypt R3, O=Let's Encrypt
Validity:
  Not Before: 2025-01-01
  Not After:  2025-04-01
Subject: CN=example.com
Public Key: RSA 2048 bits
SAN: DNS:example.com, DNS:www.example.com
CA Signature: [bytes]
# Inspect a certificate
openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -noout -text

Chain of Trust

No server uses the Root CA directly. The chain is:

Root CA (self-signed, stored in OS/browser trust store)
  └── Intermediate CA (signed by Root)
        └── Server Certificate (signed by Intermediate)

This hierarchy isolates the Root CA — it stays offline. Compromising the Intermediate does not break the entire PKI.

Certificate Types

TypeValidationUse Case
DVDomainRegular websites
OVOrganizationBusinesses
EVExtendedBanks, e-commerce
WildcardDomain*.example.com

Revocation: CRL and OCSP

Certificates can be revoked before expiry (compromised key, ownership change).

CRL (Certificate Revocation List): a list published by the CA containing revoked serial numbers. Heavy, updated periodically.

OCSP (Online Certificate Status Protocol): real-time query to the CA’s server.

# Check OCSP status of a certificate
openssl ocsp -issuer chain.pem -cert server.pem \
  -url http://ocsp.example.com -resp_text

OCSP Stapling: the server performs the OCSP query and includes the signed response in the TLS handshake, preventing the client from querying the CA directly (faster and privacy-preserving).

ssl_stapling on;
ssl_stapling_verify on;
resolver 1.1.1.1 valid=60s;

Certificate Transparency (CT)

Public, auditable logs where all certificate issuances are recorded. Modern browsers require SCTs (Signed Certificate Timestamps) in the certificate before accepting it.

This allows fraudulent issuances to be detected quickly.