Notes
A certificate
A certificate is a signed statement. It says: this public key belongs to this name. The format is called X five oh nine. Inside are the subject, the DNS names it covers, the public key, the issuer who signed it, the validity dates, what the key may be used for, a serial number, and the issuer's signature over everything. The certificate is public. The matching private key stays on the server and is never part of it.
- subject: who it is for subject alternative names: the DNS names it covers
- the public key
- issuer: who signed it
- valid from / valid until key usage and constraints
- serial number
- the issuer's signature over all of the above
Chain of trust
Trust works as a chain. At the top is a root certificate authority. It signs its own certificate, its key is kept offline, and its certificate ships inside your operating system and browser: about a hundred and fifty of them. The root signs intermediate authorities, which do the daily issuing. An intermediate signs the server certificate, called the leaf. The server sends the leaf and the intermediates, and your client connects them to a root it already has.
- root CA: self-signed, kept offline, shipped in your OS and browser trust store
- intermediate CA: signed by the root; does daily issuing
- leaf: the server certificate, signed by the intermediate
- a server sends leaf plus intermediates, not the root
Build one
You can build this yourself in a minute, and you should, once. First we create a practice root: a key and a self-signed certificate. Then, for the server, a new key and a certificate signing request, which contains the name and the public key. Finally the authority signs the request and produces the certificate, valid for ninety days. Notice that the server's private key never went to the authority. Only the request did.
openssl req -x509 -newkey ec ... \ -keyout ca.key -out ca.crt \ -subj "/CN=Practice Root CA" openssl req -newkey ec ... \ -keyout srv.key -out srv.csr \ -subj "/CN=shop.example.test" openssl x509 -req -in srv.csr \ -CA ca.crt -CAkey ca.key \ -days 90 -extfile ext.cnf \ -out srv.crt
Read one
Here is that certificate, read back. The subject and the issuer. Valid from the second of December to the second of March. The subject alternative name, which is the field clients actually match against the hostname. Basic constraints say C A false, so this certificate cannot sign other certificates. Key usage allows digital signatures, and extended key usage says it is for server authentication. The whole file is six hundred and seventy six bytes.
subject=CN = shop.example.test
issuer=CN = Practice Root CA
notBefore=Dec 2 22:05:59 2026 GMT
notAfter=Mar 2 22:05:59 2027 GMT
Subject Alternative Name:
DNS:shop.example.test
Basic Constraints: CA:FALSE
Key Usage: Digital Signature
Extended Key Usage:
TLS Web Server Authentication What the client checks
When a client receives a certificate it checks several things, and all must pass. Each signature in the chain verifies, ending at a root in its trust store. Today's date is inside the validity period. The hostname it wanted matches a subject alternative name. The usage fields allow this purpose. And the certificate has not been revoked. Separately, during the handshake, the server proves it holds the private key by signing with it.
- 1. each signature in the chain verifies, up to a trusted root
- 2. today is inside the validity dates
- 3. the hostname matches a subject alternative name
- 4. usage allows this purpose
- 5. it is not revoked
- then the server proves it has the private key
Watch it fail
Here are those checks failing. With our practice root supplied, verification says OK. Without it, the client does not know the issuer: error twenty, unable to get local issuer certificate. That is the classic error for a private authority or a missing intermediate. And when we asked whether the certificate is valid for a different hostname, error sixty two, hostname mismatch. A valid certificate for the wrong name is not valid.
$ openssl verify -CAfile ca.crt srv.crt srv.crt: OK $ openssl verify srv.crt error 20: unable to get local issuer certificate $ ... -verify_hostname evil.example.test error 62: hostname mismatch
Getting a certificate
To get a public certificate you prove that you control the domain, by publishing a DNS record or serving a file. The ACME protocol automates this, which is how Let's Encrypt, cert-manager and cloud certificate managers issue and renew without people. Lifetimes keep shrinking: ninety days is normal and the industry is moving shorter. That makes automation a requirement. An expired certificate is one of the most common causes of outages.
- domain validation: prove control via DNS record or an HTTP file
- ACME automates it: Let's Encrypt, cert-manager, cloud certificate managers
- lifetimes keep shrinking: 90 days is normal, shorter is coming; automate renewal
- wildcards: one key, many hosts
Revocation and CT
If a private key leaks, the certificate must be revoked, through revocation lists or the OCSP lookup protocol. In practice, clients check these unreliably, which is the real reason lifetimes are getting shorter. Certificate Transparency is the other safeguard: every public certificate is recorded in public logs. Monitor those logs for your domains, and you will see any certificate issued without your knowledge. A CAA record in DNS says which authorities may issue for you.
- revocation: CRLs (lists) and OCSP (live lookup); both are checked unreliably
- so: short lifetimes limit the damage of a stolen key
- Certificate Transparency: every public certificate goes into public logs
- monitor the logs for your domains (crt.sh)
- CAA records: who may issue
Internal PKI
Inside a company you usually run a private authority. It issues certificates for internal services, for mutual TLS between services, for devices, and for VPN and Wi-Fi logins. Tools include step-ca, the Vault PKI engine, cloud private authorities and Active Directory Certificate Services. Keep the root key offline or in a hardware module, and issue short-lived certificates automatically. Whoever controls the authority's key can create an identity for anything, so it is a top target.
- for: internal services, mTLS between services, devices, VPN and Wi-Fi logins
- tools: step-ca, Vault PKI, AWS Private CA, AD CS
- root key offline or in an HSM
- issue short-lived certs, automatically
- the CA key can mint identity for anything: guard it
How attackers abuse it
Attackers aim at trust, not at mathematics. The easiest win is a client with verification switched off, which accepts any certificate. Malware adds a rogue root to a device's trust store, then intercepts everything. Private keys are stolen. Occasionally an authority is compromised and issues certificates for domains it should not. And in Windows networks, misconfigured certificate templates let ordinary users request certificates for administrators.
- clients with verification turned off (verify=False)
- a rogue root added to a device trust store
- stolen private keys
- a compromised or careless CA issuing for your domain
- misconfigured AD CS templates that let users request admin certificates
- forgotten, expired certs
Common mistakes
Mistakes. Certificate verification disabled in code, often added during testing and never removed. Renewals done by hand from a calendar reminder. No monitoring of expiry dates. A server that sends the leaf without its intermediates, which works in some clients and fails in others. One wildcard key copied to every server. Private keys committed to repositories. Internal certificates valid for ten years. And nobody watching the transparency logs.
- verify=False or -k in code
- renewals done by hand
- no expiry monitoring
- serving the leaf without its intermediates
- one wildcard key copied to every server
- private keys in repos
- long-lived internal certs
- nobody watching CT logs
Say it like this
In the interview: the browser builds a chain from the server certificate through the intermediates to a root in its trust store, verifying each signature. It checks the validity dates, that the hostname matches a subject alternative name, the key usage, and revocation status. Then the server proves it holds the private key by signing the handshake. I would add that I automate issuance and renewal, and monitor expiry and Certificate Transparency.
- "It builds a chain from the leaf through intermediates to a root in its trust store, verifying each signature. It
- checks dates, that the name
- matches a SAN, usage, and revocation. The server proves
- possession of the private key
- in the handshake."