Introduction
When your browser shows that lock icon, a whole machinery of cryptographic verification is running behind the scenes. Browsers don’t “just trust” websites they follow a detailed, layered process anchored in something called
Public Key Infrastructure (PKI). And while most developers understand HTTPS at a high level, PKI often feels like a mysterious box of keys, certificates, and authorities.
This guide breaks everything down in simple, direct language. Just clear explanations, diagrams, and small hands-on openssl commands you can try yourself.
Let’s unpack how browsers actually decide whom to trust.
PKI Basics: Why the Lock Icon Matters
PKI exists because the internet doesn’t have a built-in identity system. Anyone can pretend to be anyone unless there’s a reliable way to:
- Confirm identity (Is this really example.com?)
- Ensure privacy (No one can read your traffic)
- Guarantee integrity (No one tampered with data in transit)
That little lock icon means:
- Your connection is encrypted using TLS
- The website has a valid certificate
- The certificate chains up to a trusted authority
It doesn’t mean the site is good, ethical, or legitimate just that the browser can verify who it claims to be.
Certificates and Key Pairs
Every certificate depends on a public/private key pair:
- Private key: kept secret by the server
- Public key: shared openly in the certificate
The certificate itself is basically an ID card for a website. It includes:
- Domain name
- Public key
- Issuer (the CA that signed it)
- Validity dates
- Extensions like SAN (Subject Alternative Name)
Try inspecting a certificate:
openssl s_client -connect example.com:443 -showcertsOr view details:
echo | openssl s_client -connect example.com:443 -servername example.com | openssl x509 -text -nooutLook for:
- Issuer - who signed the certificate
- Subject - which domain the certificate belongs to
- SAN - the actual list of allowed hostnames
- Not Before / Not After - expiration time
- Signature Algorithm - e.g., SHA-256
3. The Trust Chain
Browsers don’t trust certificates directly they trust Root Certificate Authorities (Root CAs). These roots are pre-installed in your browser or OS.
The chain typically looks like this:
Root CAs
Stored in the browser/OS trust store. Extremely protected.
Intermediate CAs
Issued by root CAs. They issue server certificates.
Server Certificates
Used by actual websites. Must chain back to a trusted root.
If the chain is broken or an intermediate is missing the certificate fails even if it’s technically valid.
4. Validation in TLS Handshake
When you open a website, your browser performs a TLS handshake and validates certificates along the way.
Here’s a simplified flow:
The browser must confirm:
- The certificate isn’t expired
- The SAN field matches the domain
- The chain links to a trusted root
- The certificate is not revoked
- The signature is valid
A failure at any step triggers a browser warning.
5. Certificate Types
DV - Domain Validation
- Automatic
- Proves domain control
- Most common (including Let’s Encrypt)
OV - Organization Validation
- CA verifies business identity
- Provides minimal visible benefit today
EV - Extended Validation
- Deep legal and business checks
- Browsers used to highlight EV, but UI emphasis has faded
SAN - Subject Alternative Name
Lists all valid hostnames. Modern browsers ignore CN for validation SAN is what matters.
Wildcard Certificates
Cover all subdomains, e.g. *.example.com
Convenient but riskier: if the key leaks, a lot of domains are compromised.
6. Trust Stores and Self-Signed Certificates
Trust stores are collections of Root CAs baked into:
- Windows
- macOS/iOS
- Android
- Firefox (maintains its own store)
A certificate is trusted only if the chain reaches a root in the store.
A self-signed certificate skips all this and signs itself.
Browsers respond with: “That's cute, but… no.”
Self-signed certs only work if the user manually adds the root to their trust store fine for local dev or internal systems, not the public internet.
7. Certificate Revocation
Certificates sometimes need to be invalidated early, such as when:
- A private key leaks
- A domain changes ownership
- A CA issues a certificate incorrectly
CRL - Certificate Revocation List
A downloadable list of revoked certificates. Slow, bulky, rarely used by browsers today.
OCSP - Online Certificate Status Protocol
Browser asks the CA in real time: “Is this certificate still valid?”
Downsides:
- Adds latency
- Leaks user browsing behavior
OCSP Stapling
The server gets its own OCSP response and “staples” it to the TLS handshake.
Benefits:
- Fast
- Private
- Reliable
8. Automation with ACME and Let’s Encrypt
Let’s Encrypt changed everything by introducing:
- Free certificates
- Fully automated issuance
- 90-day certificates
- The ACME protocol
Automation reduces outages and security risk shorter lifetimes mean compromised keys matter for less time.
Check a Let’s Encrypt certificate:
openssl req -x509 -newkey rsa:2048 -nodes -days 365 \
-subj "/CN=localhost" \
-keyout key.pem -out >(openssl x509 -text -noout)Look for “Let’s Encrypt Authority X3” or similar in the Issuer field.
9. Private PKI and Internal Services
For internal systems Kubernetes clusters, service meshes, CI systems teams often run a Private PKI.
Benefits
- Full control
- Custom policies
- No external CA dependency
- Works offline
Catches
Every device must trust the private root CA or else every site looks “unsafe.”
This is where tools like:
- HashiCorp Vault
- Smallstep CA
- Cloud-based private CAs
come in handy.
10. Common Misconfigurations and Real-World Risks
Even well-run teams slip up. Common issues include:
Expired Certificates
Still one of the biggest causes of outages. (Yes even Google, Microsoft, and major CDNs have been burned.)
Missing Intermediate Certificates
If the server doesn’t send the full chain, validation fails.
Incorrect SANs
If the domain isn’t listed in SAN, it’s invalid period.
Weak Keys
1024-bit RSA or deprecated algorithms like SHA-1 can break security.
Leaked Private Keys
If the key leaks, attackers can impersonate your site.
Revocation Failures
Servers forgetting to staple OCSP responses, causing browser delays or failures.
Hands-On Certificate Inspection with openssl
Try fetching and inspecting a certificate:
echo | openssl s_client -connect example.com:443 \
-servername example.com \
-showcerts | openssl x509 \
-text -nooutCheck:
Issuer:Subject:X509v3 Subject Alternative Name:Not Before:Not After:
This helps troubleshoot hostname mismatches, expiry issues, or chain problems.
References
- What is Public Key Infrastructure (PKI)? → Straightforward intro to PKI basics and secure key distribution.
- How Does HTTPS Work Internally? → Breaks down HTTPS, SSL/TLS certificates, and CAs for browsing security.
- Self-signed PKI for the homelab → Practical guide to self-signed PKI with SAN for homelab setups.
- SSL Certificate: Complete Guide → Covers types of SSL/TLS certs, wildcards, and multi-domain SANs.
Conclusion
PKI is the backbone of secure communication on the modern internet. Whether you're building APIs, deploying Kubernetes clusters, or spinning up a simple web app, understanding how browsers decide whom to trust helps you avoid outages, misconfigurations, and security risks. I recently made a PKI Toolkit in rust, Do check it out and give a 🌟 if you like it. From trust chains to automation to revocation, PKI quietly protects billions of connections every day. And now, you know exactly how that little lock icon earns its keep.
