PKI, Certificates & Key Management
PKI, Chα»©ng chα» & QuαΊ£n lΓ½ KhΓ³a
Key Terms
PKI Hierarchy β Chain of Trust
PKI (Public Key Infrastructure) is a framework for managing digital certificates and public-private key pairs. It establishes a chain of trust from a Root CA down to individual certificates.
PKI Component Roles
| Component | Role | Key Property |
|---|---|---|
| Root CA | Top of trust hierarchy; signs Intermediate CAs | Must be OFFLINE (air-gapped) |
| Intermediate CA | Online; signs end-entity certificates; limits Root CA exposure | Revocable without invalidating Root CA |
| End-entity Cert | Issued to server/user; contains public key + identity | Short validity; must be regularly renewed |
| RA (Registration Authority) | Verifies identity before certificate issuance; outsources vetting from CA | Trusted identity verification agent |
| CRL (Cert Revocation List) | List of revoked certificate serial numbers published periodically by CA | Stale β may not reflect recent revocations |
| OCSP | Real-time single-certificate revocation check via HTTP | Fresh β real-time status |
| OCSP Stapling | Server pre-fetches signed OCSP response and includes it in TLS handshake | Eliminates client round-trip to OCSP responder; better performance & privacy |
Certificate Revocation: CRL vs. OCSP
- Batch list of revoked certificate serial numbers
- Published periodically (daily or weekly)
- Client downloads entire list
- Can be STALE β recent revocations may not appear until next publication
- Large files as PKI grows (performance issue)
- Real-time query for a single certificate's status
- Client sends certificate serial number; OCSP responder replies: Good / Revoked / Unknown
- Always FRESH β reflects current revocation status
- Privacy concern: OCSP responder knows which sites you're visiting
- OCSP Stapling solves the privacy concern
Key Storage Hardware
| Device | Type | FIPS Level | Use Case | Key Property |
|---|---|---|---|---|
| HSM | Hardware Security Module | FIPS 140-2 Level 3+ | Server-side key storage, CA key protection, bulk crypto operations | Tamper-evident. Keys never leave HSM in plaintext. Physical destruction on tamper detected. |
| TPM | Trusted Platform Module | FIPS 140-2 Level 1-2 | Laptop/workstation β disk encryption (BitLocker), platform attestation | Chip on motherboard. Seals keys to platform measurements. Cannot be transplanted. |
| HashiCorp Vault | Software (with HSM backend option) | N/A (software) β can use HSM backend for FIPS | Cloud-native secret management, dynamic secrets, key/value secrets | Used by FinTech Company X. Lease-based access. Audit logging. Vault Agent for K8s injection. |
FIPS 140-2 Level 3 requires tamper-evidence, identity-based authentication, and zeroization of plaintext CSPs on tamper. Level 4 adds physical security envelope with environmental failure protections.
Key Management Lifecycle
Key Escrow vs. Key Rotation
| Concept | Definition | Risk | Use Case |
|---|---|---|---|
| Key Escrow | A copy of the encryption key is held by a trusted third party for recovery purposes | Third party becomes a high-value target; compromise of escrow = compromise of all data | Government-mandated lawful intercept; enterprise data recovery (Vault key backup) |
| Key Rotation | Periodic replacement of keys with new ones; old key decrypts old data during transition | Operational complexity; window where both old and new keys must be valid | Limit key exposure window; compliance (PCI-DSS requires annual rotation); after personnel change |
- CRL = batch list (stale); OCSP = real-time single cert (fresh) β OCSP is preferred for revocation checks. CRL may not reflect recent revocations.
- Root CA MUST be OFFLINE β if the Root CA is compromised, every certificate it issued (directly or through Intermediates) must be treated as invalid. An online Root CA is a critical security failure.
- HSM provides hardware-protected key storage β more secure than software-only (Vault without HSM backend). Keys never leave the HSM in plaintext.
- Certificate pinning defeats MITM attacks via rogue CAs β even if an attacker controls a trusted CA that issues a fraudulent certificate for your domain, pinning rejects it.
- Key escrow = recovery capability BUT creates third-party risk β the escrow holder becomes a target. Government escrow (Clipper chip era) is controversial precisely for this reason.
- OCSP Stapling = server fetches OCSP response and staples it to TLS handshake β eliminates client's need to contact OCSP responder (better privacy and performance).
- JWT RSA private keys: Stored only in HashiCorp Vault (never in Kubernetes Secrets, environment variables, or config files). Vault audit log records every read of the private key material.
- Zero-downtime key rotation: RSA JWT signing key pairs rotated annually. During the rotation window (48 hours), the JWKS endpoint serves BOTH the old and new public keys. Services verify tokens against all active public keys β no token rejections during rotation.
- TLS certificate automation: cert-manager in Kubernetes automates Let's Encrypt certificate renewal (renews at 60 days, valid for 90 days). No manual renewal β eliminates expiry-related outages.
- Per-tenant AES data keys: AES-256-CTR data encryption keys stored in Vault with per-tenant isolation. Partner A encryption key is different from Partner D encryption key β a Vault compromise of one tenant's key does not expose another tenant's data.
Practice Questions
Q1. A browser checks whether a web server's TLS certificate has been revoked. The browser queries the certificate's revocation status in real time for a single certificate. Which method is being used?
A. OCSP (Online Certificate Status Protocol) β real-time single-certificate revocation checkQ2. An organization's PKI Root CA is connected to the network for daily operations. A security auditor flags this as a critical finding. Why is an online Root CA a security risk?
A. If the Root CA is compromised, ALL certificates in the PKI hierarchy are invalidated β the Root CA must be offline to protect the entire trust chainQ3. An organization needs to protect server-side RSA private keys for a payment processing system. Which hardware device provides the highest level of key protection with tamper detection?
A. HSM (Hardware Security Module) β FIPS 140-2 Level 3+, tamper-evident, keys never exported in plaintextQ4. A mobile banking application hardcodes the SHA-256 hash of the server's public key. During a security audit, a penetration tester intercepts traffic using a corporate proxy with a trusted CA certificate. The app rejects the proxy's certificate. What security control prevented the interception?
A. Certificate pinning β the app rejects any certificate whose public key hash does not match the pinned value, even if the certificate is signed by a trusted CAQ5. An organization rotates its RSA JWT signing keys annually. During the rotation process, the old JWT signing key is kept active for 48 hours alongside the new key. Why is this necessary?
A. Tokens signed with the old key may still be valid (within their TTL) during the rotation window β services must accept both keys to avoid rejecting legitimate tokens