Cryptography / Infrastructure

Public Key Infrastructure (PKI) & X.509 Certificates

Public Key Infrastructure (PKI) binds public keys to an identifier vetted by a trusted Certificate Authority (CA), using digital signatures. What that identifier actually proves depends on the validation level: the overwhelming majority of publicly-trusted TLS certificates today are Domain Validated (DV), meaning the CA confirmed the applicant controls the domain name — not that it verified any real-world organizational identity behind it. Organization Validated (OV) and Extended Validation (EV) certificates additionally vet a legal entity, but DV is the default for most web traffic. X.509 certificates provide the trust anchor for TLS, S/MIME, code signing, and mutual TLS (mTLS) identity verification across open networks.

Core PKI Components & Trust Model

PKI commonly uses a hierarchy where trusted Root CAs issue certificates to Intermediate CAs, which in turn issue leaf or end-entity certificates. Publicly trusted TLS subscriber certificates are increasingly short-lived under CA/Browser Forum policy; S/MIME, code-signing, private-PKI, and other end-entity certificate profiles can use different validity periods.

PKI Certificate Authority hierarchy showing Root CA signing Intermediate CA, which signs leaf server certificates.

PKI trust hierarchy: Root CA delegates signing authority to Intermediate CAs

PKI Component Operational Role Primary Security Property
Certificate Authority (CA) Trusted entity that vets an identifier and signs X.509 certificates Private key custody inside HSM; protects root of trust.
Certificate Revocation List (CRL) / OCSP Revocation status mechanisms publishing invalid certificate serial numbers Best-effort defense against compromised or misissued certificates — most browsers soft-fail (proceed with the connection) when a revocation check is unavailable, so it is not an absolute guarantee.
Registration Authority (RA) Verifies domain control (DV) or, for OV/EV issuance, organizational identity, prior to issuance Enforces domain control validation (DNS-01, HTTP-01) for DV; additional business-registry checks for OV/EV.
Trust Store Pre-installed list of trusted Root CA certificates embedded in OS / browser Establishes local trust anchors used during path validation (RFC 5280 §6): chain building to a trusted root, signature verification at each hop, validity-period and name-constraint checks, and — where enforced — revocation status.

What “Validating a Certificate” Actually Means

“Certificate validation” bundles together several distinct checks that a client must perform, and a failure in any one of them is a different failure mode from the others:

  1. Path Building: Given a leaf certificate, locate a chain of intermediate certificates connecting it to a Root CA already present in the local trust store. A server that omits a required intermediate, or presents intermediates out of order, can cause path building to fail even when a valid chain exists in principle — this is why “include the full intermediate chain” is standard TLS deployment advice.
  2. Path Validation: For the chain path building found, cryptographically verify each signature (leaf signed by intermediate, intermediate signed by root), confirm each certificate is within its validity window, and check policy constraints (basic constraints, name constraints, key usage/EKU) at every hop per RFC 5280 §6. This confirms the chain is cryptographically well-formed and policy-compliant — it does not yet confirm the certificate belongs to the host the client is talking to.
  3. Endpoint (Hostname) Verification: Separately from chain validation, the client must confirm the hostname it intended to connect to appears in the certificate’s Subject Alternative Name (SAN) field, per RFC 9525 (which obsoletes the earlier RFC 6125). This step is easy to omit in custom TLS client code (hence a long history of vulnerabilities where a valid, trusted certificate for any domain was accepted for connections to every domain) and is worth calling out explicitly: a chain can pass path validation perfectly while still being the wrong certificate for the connection, if hostname verification isn’t performed.
  4. Revocation Checking: Query CRL or OCSP (see below) to confirm the certificate hasn’t been revoked since issuance — a check that is best-effort in most real deployments (see the Trust Store row above) rather than a hard requirement.
  5. Certificate Transparency: Separately, confirm the certificate carries the SCTs a given browser vendor’s policy requires (see Certificate Transparency) — a detection mechanism for rogue issuance, not part of RFC 5280 path validation itself.

Treating these as one monolithic “is this cert valid?” check, rather than as separable phases each with its own failure mode, is a common source of both security bugs (skipped hostname verification) and operational bugs (misdiagnosing a path-building failure as a revocation problem, or vice versa).

Anatomy of an X.509 v3 Certificate (RFC 5280)

Specified in RFC 5280, an X.509 v3 certificate structures identity metadata into standard fields signed by a CA:

Live CT Issuance Inspector

Domain CT Log Issuance Inspector

Enter any public domain name (e.g. google.com, github.com) to query its Certificate Transparency (CT) log issuance records via CertSpotter API. Shows the most recent issuance among the certificates returned by a single API page — a domain with an unusually large issuance history could have newer certificates beyond that page (see code comment).

Field Name Standard Function Critical Security Check
Basic Constraints Indicates whether subject is a CA (cA: TRUE vs cA: FALSE) Leaf certificates must never assert cA: TRUE. Depending on the issuing CA’s profile, they either omit this extension entirely (which defaults to non-CA per RFC 5280 §4.2.1.9) or include it explicitly set to cA: FALSE — either form prevents the leaf key from minting further certificates.
Extended Key Usage (EKU) Specifies the purposes relying applications should accept the certificate for (Server Auth, Client Auth, Code Signing), per RFC 5280 §4.2.1.12 Signals that a well-behaved code-signing verifier should reject a signature made with a Server-Auth-only certificate — it constrains what compliant relying parties accept, not what the private key is physically capable of signing; the key itself can still produce a mathematically valid signature over anything.
Subject Alternative Name (SAN) Lists the identifiers bound to this certificate — not just exact FQDNs: dNSName entries (including wildcards like *.example.com), iPAddress entries, and other GeneralName forms (e.g. otherName, email/URI where applicable) For public Web PKI browser TLS, the requested DNS name or IP address is matched against the corresponding SAN identifier and does not fall back to commonName (CN), as described by RFC 9525. Other X.509 use cases apply their own governing profiles and are outside RFC 9525’s service-identity scope.
Validity Period Defines Not Before and Not After timestamp bounds For publicly-trusted TLS subscriber (server/leaf) certificates specifically, the CA/Browser Forum Baseline Requirements cap maximum validity at 200 days as of March 15, 2026; 100 days as of March 15, 2027; and 47 days as of March 15, 2029. These caps do not apply to private/internal PKI, most S/MIME or code-signing certificates, or CA (root/intermediate) certificates, which follow different lifetime rules.

Certificate Lifecycle & Automated Issuance (ACME & ARI)

Managing short-lived certificates at scale requires automated enrollment via the Automated Certificate Management Environment (ACME / RFC 8555) protocol:

Automated ACME certificate lifecycle showing CSR submission, domain-control validation, CA issuance, ARI-guided renewal, and a separate best-effort emergency revocation path whose client behavior varies.

Automated ACME lifecycle: domain validation, issuance, renewal, and a layered revocation path whose coverage, freshness, and failure behavior depend on the relying party

Certificate Lifetime Shrinkage Timeline

Timeline showing X.509 certificate maximum lifetimes shrinking from 825 days down to 47 days.

Publicly-trusted TLS subscriber certificate lifetime evolution: transition from multi-year (825-day) static certificates to automated short-lived certificates, tightening from 200 days today to a 47-day maximum by March 2029

ACME Renewal Information (ARI, RFC 9773)

To support these shrinking (200-day today, 47-day by 2029) certificate lifetimes without outages, ACME Renewal Information (ARI) (RFC 9773, published as a Proposed Standard in 2025) allows CAs to suggest optimal renewal windows to automated agents dynamically before expiration.

Revocation in Practice: Why It’s Not Uniformly Reliable

Revocation exists to handle the case a certificate’s validity period can’t: a key compromised, or a certificate mis-issued, before it would naturally expire. In practice, no single revocation mechanism gives every client a fast, reliable answer, which is exactly why the “best-effort” framing appears repeatedly on this page rather than a flat guarantee.

The practical upshot: revocation checking is a layered, best-effort defense with real gaps at every layer (staleness, soft-fail, partial coverage), not a single reliable mechanism — which is also why shrinking certificate lifetimes are treated as a complementary mitigation, not a replacement for revocation.

Certificate Formats & OpenSSL Encoding Conversions

X.509 certificates and private keys show up under five commonly seen format markers — though these aren’t five instances of one consistent category: PEM and DER are encodings (ASCII-armored vs. binary ASN.1), PKCS#7 and PKCS#12 are containers (bundling multiple objects together), and .crt/.cer is an ambiguous file extension that says nothing about the underlying encoding on its own:

Format Extension Encoding Type Typical Content Target Application Use Case
.pem Base64 ASCII with -----BEGIN ... ----- armor Certificates, Private Keys, CSRs, CA Chains Standard default for Linux, NGINX, Apache, and OpenSSL.
.der Binary ASN.1 encoding Single Certificate or Private Key A DER-encoded certificate imported into a Java KeyStore (JKS) or PKCS#12 store, Windows OS binary certs, smart cards — DER itself is a certificate/key encoding, not a keystore format.
.crt / .cer Ambiguous — either Base64 PEM or binary DER, depending on platform/tool Single Certificate (rarely a private key) The extension alone does not tell you the encoding; inspect the file (file cert.crt or look for a -----BEGIN header) before assuming a format.
.p7b / .p7c PKCS#7 container (Base64 or binary) Certificate Bundles & CRLs (No Private Keys) Windows IIS, S/MIME email signature verification.
.pfx / .p12 PKCS#12 password-protected binary container Bundles Leaf Cert + Private Key + CA Chain Windows IIS, Tomcat, macOS Keychain, Android system certs.

OpenSSL CLI Reference Cheat Sheet

Interactive Command Generator

OpenSSL CLI Code Generator

Select any common certificate operation below, customize variables, and copy the exact syntax required for your local console terminal.

Certificate & Public Key Pinning (Mobile & Native App Defense)

Standard PKI path validation trusts any applicable pre-installed Root CA in an OS trust store — meaning any root whose path constraints and policies permit issuance for your domain and certificate purpose — to issue certificates for your domain. The exact count of trusted roots varies by platform and OS version, but is commonly on the order of 100+; not every one of those roots is actually unconstrained for every domain, since name-constrained or policy-constrained intermediates can narrow which roots can issue for a given name in practice. Certificate Pinning (or Public Key Pinning) adds an additional restriction on top of standard X.509 path validation and hostname verification — it does not replace or skip them. A pinned connection still must pass ordinary chain building, signature verification, and name checking; pinning then further requires that a specific, pre-declared public key hash also appear in the chain, narrowing acceptance from “any trusted Root CA in the OS store” down to a pre-declared set (often the server’s own SPKI plus one or more backup pins, not necessarily a single key).

Pinning Target Strategies

Pinning Strategy Target Object Pinned Maintenance & Operational Risk Primary Use Case
Leaf Certificate Pinning Hashes full leaf X.509 certificate Highest rotation sensitivity: Leaf cert expiration or emergency ACME renewal breaks app connectivity unless an app update is deployed. High-security ephemeral IoT sessions.
Intermediate / Root CA Pinning Hashes public key of issuing CA Lower certificate-renewal sensitivity: Leaf certs can rotate freely, but issuing CA key rotation or intermediate retirement breaks client connections. Enterprise mobile applications.
SPKI Public Key Pinning Hashes the complete DER-encoded SubjectPublicKeyInfo structure — the algorithm identifier plus the public key bit string together, per RFC 7469, not the bit string alone Survives certificate renewal only while pinned key remains unchanged: Re-issuing leaf certs using the same key pair maintains pin validity, but key compromise or key rotation without a valid backup pin breaks connectivity. Native mobile app transport security.

Pinning Scope: Public CA vs. Private CA Deployment

Certificate pinning applies to both Public PKI and Private PKI environments, addressing distinct threat vectors:

Security Risks & Threat Vectors of Pinning

While pinning protects network transport against rogue CAs, it introduces significant security trade-offs and threat vectors:

Security Risk / Threat Vector Attack Mechanics & Impact Engineering Mitigation
Self-Inflicted Security DoS If an emergency key revocation occurs (e.g. private key leak) and no matching backup pin exists in the app binary, deployed client instances lose API connectivity, preventing over-the-air API security patches. Always configure at least one Backup SPKI Pin derived from an offline, cold-storage key pair.
Pin-Jacking / Hostage Attack An attacker who briefly compromises server header configurations can inject malicious pins, locking legitimate clients out of the legitimate service indefinitely. Primary reason HPKP was deprecated in browsers. Restrict pinning configurations to signed native app code bundles.
Client-Side Bypass (Frida / Jailbreak) Attackers analyzing mobile apps on rooted/jailbroken devices easily bypass pinning using dynamic instrumentation tools (Frida, Objection) to hook TLS validation routines. Treat pinning as a network-layer defense, not a client-side reverse engineering barrier. Combine with root/jailbreak detection and obfuscation.
CA Intermediate Migration Failure If an issuing CA retires an Intermediate certificate authority (e.g. Let’s Encrypt R3 to R10), pinned clients that hardcoded the Intermediate CA key drop connection. Pin SubjectPublicKeyInfo (SPKI) of your own key pair, or pin the Root CA key rather than transient Intermediate keys.
Pinning Industry Guidance & Deprecation Warning
Web Browsers (Deprecated) vs. Mobile Native Apps (Situational)

Understanding where Certificate Pinning belongs prevents catastrophic self-inflicted Denial of Service (DoS):

  • Web Browsers (Deprecated): HTTP Public Key Pinning (HPKP), specified by RFC 7469, is no longer a deployable web-platform control in major browsers. Chromium announced deprecation and removal of HTTP-based dynamic pinning for Chrome 67; Mozilla disabled HPKP by default and then removed HPKP header and cached-pin processing in Firefox 78. Public-web defenses now rely on browser CT policy and other platform controls rather than a site-supplied HPKP header.
  • Mobile & Native Apps (Situational — Use Deliberately): Certificate and SPKI pinning can add defense-in-depth for iOS and Android native applications against corporate TLS proxies, local MitM interception, and rogue CA issuance. However, both platform vendors caution against reaching for static public key pinning by default: Android's official guidance and Apple's PKI guidance advise that pinning carries high operational risk during key rotation, recommending it only for applications with a specific, well-understood threat model and a tested pin-rotation process.
  • Backup Pin Recommendation Rule: If you choose to deploy pinning, mobile app configurations are strongly recommended to specify at least one backup pin (a secondary public key hash held in cold storage) to allow key rotation without bricking deployed application instances (Android's documentation advises including a backup pin, though schema validation itself does not block single-pin blocks).

Native Mobile Pinning Configuration Examples

Android Network Security Config (res/xml/network_security_config.xml)

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="false">
        <domain includeSubdomains="true">api.example.com</domain>
        <pin-set expiration="2027-01-01">
            <!-- Primary Pin: SHA-256 hash of SubjectPublicKeyInfo -->
            <pin digest="SHA-256">cUPcScTJnGGxEvWYspA5vF9VPol17BskT1hB64GVAHw=</pin>
            <!-- Backup Disaster Recovery Pin (Cold Storage Key) -->
            <pin digest="SHA-256">M8HwxWaMH1ECCkg4AgWFiUsS55TF0bT3A89LBFJgMqU=</pin>
        </pin-set>
    </domain-config>
</network-security-config>

iOS Network Transport Security (Info.plist)

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSPinnedDomains</key>
    <dict>
        <key>api.example.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSPinnedCAIdentities</key>
            <array>
                <dict>
                    <key>SPKI-SHA256-BASE64</key>
                    <string>cUPcScTJnGGxEvWYspA5vF9VPol17BskT1hB64GVAHw=</string>
                </dict>
                <dict>
                    <key>SPKI-SHA256-BASE64</key>
                    <string>M8HwxWaMH1ECCkg4AgWFiUsS55TF0bT3A89LBFJgMqU=</string>
                </dict>
            </array>
        </dict>
    </dict>
</dict>

Post-Quantum Hybrid Certificates

As PKI migrates toward quantum safety, Certificate Authorities and standards groups (IETF LAMPS working group) are standardizing Post-Quantum Hybrid Certificates:

What I need to remember

Root CAs sign intermediates, which sign leaf certificates; path validation does not replace hostname verification against the leaf certificate's SAN. As public TLS validity periods shrink, automate issuance and renewal at scale. ACME is one standardized automation protocol, and ARI lets supporting CAs suggest renewal windows; ARI improves scheduling but is not required for renewal.

Primary references