Skip to content
Vol. 1 · Ed. 2026
CyberGlossary
Entry № 178

Certificate Pinning

Reviewed byCybersecurity entrepreneur & security researcher

What is Certificate Pinning?

Certificate PinningA technique in which an application hard-codes an expected certificate or public key and refuses TLS connections that do not match, defeating rogue or compromised CAs.


Certificate pinning binds a specific TLS server to one or more cryptographic identities — a full leaf certificate, an intermediate, or a SubjectPublicKeyInfo (SPKI) hash — that the client trusts implicitly. During the handshake the client compares the server's chain against the pinned values and aborts on mismatch, even if the chain is signed by a publicly trusted CA. This defeats an attacker holding a fraudulent-but-valid certificate, such as one issued by a compromised or coerced CA (the 2011 DigiNotar and Comodo incidents that led to rogue Google certificates being the classic motivation).

Browser HPKP vs. app pinning

The web tried pinning via HTTP Public Key Pinning (HPKP, RFC 7469, 2015), a Public-Key-Pins response header. It failed in practice: a lost key, a routine rotation without updating pins, or a hostile "RansomPKP" injection could lock users out for the whole max-age. Chrome deprecated HPKP in 2017 and removed it in Chrome 72 (2018), ceding the role to Certificate Transparency logs. Pinning survives mainly in mobile apps talking to a fixed backend (Android Network Security Config, iOS NSPinnedDomains, OkHttp CertificatePinner).

flowchart TD
  A[Client opens TLS to api.example.com] --> B[Server presents certificate chain]
  B --> C{Chain validates against system CAs?}
  C -->|No| E[Abort: standard TLS failure]
  C -->|Yes| D{SPKI hash matches a pinned key?}
  D -->|Yes| F[Connection allowed]
  D -->|No| G[Abort: pin mismatch, block MITM/rogue CA]

Weaknesses and defences

Pinning is only as good as its backup pins — always pin a rollover key. On rooted/jailbroken devices, tools like Frida and objection hook the validation routine to strip pins, so pinning raises the bar for MITM interception but is not a substitute for device attestation. Modern guidance (OWASP MASVS) favours SPKI pinning with short-lived certs and a tested rotation plan.

Examples

  1. 01

    A banking app that pins the SHA-256 hash of its server's public key and rejects any other certificate.

  2. 02

    A mobile API client that pins both the production and the rollover key as a backup.

Frequently asked questions

What is Certificate Pinning?

A technique in which an application hard-codes an expected certificate or public key and refuses TLS connections that do not match, defeating rogue or compromised CAs. It belongs to the Network Security category of cybersecurity.

What does Certificate Pinning mean?

A technique in which an application hard-codes an expected certificate or public key and refuses TLS connections that do not match, defeating rogue or compromised CAs.

How do you defend against Certificate Pinning?

Defences for Certificate Pinning typically combine technical controls and operational practices, as detailed in the full definition above.

What are other names for Certificate Pinning?

Common alternative names include: TLS pinning, Public-key pinning.

Related terms

See also