Skip to main content
tls

Certificate Pinning

Certificate pinning restricts which TLS certificates a client accepts for a specific domain, beyond standard CA validation. The client stores expected certificate hashes and rejects connections presenting different certs – even if CA-signed. Pins prevent MITM via compromised CAs but cause outages if pins are not rotated before certificate renewal.

Definition

Certificate pinning binds a domain to specific certificates or public keys, preventing acceptance of any other valid cert. Without pinning, any of the hundreds of trusted CAs could issue a certificate for your domain – a compromised or coerced CA enables government MITM surveillance. With pinning, even a valid CA-signed certificate is rejected if its hash does not match the pin. HPKP (HTTP Public Key Pinning) was a browser standard but was deprecated because misconfigured pins locked users out permanently. Mobile apps still use pinning extensively (banking, security apps) by embedding expected hashes in the app binary. Modern alternatives include Certificate Transparency (CT) log monitoring which detects unauthorized issuance without the catastrophic failure mode of hard pinning.

Examples

  • Android: <pin-set><pin digest='SHA-256'>base64hash</pin></pin-set> in network_security_config.xml
  • iOS: SSL pinning via TrustKit or URLSession delegate
  • HPKP header (deprecated): Public-Key-Pins: pin-sha256='base64'; max-age=5184000

Related Protocols

Related Terms