Certificate pinning explained in plain terms means understanding a simple act of distrust: instead of accepting any certificate signed by any authority, an app remembers the one key it expects and rejects everything else, even a certificate that is perfectly valid. The central question is why a valid certificate would ever be rejected, and the answer is that certificates can be issued by mistake, stolen, or compelled, and pinning is the refusal to trust the whole system when only one key matters.
The web’s trust model is broad by design. A browser trusts hundreds of certificate authorities, and any one of them can issue a certificate for any site, which means a single compromised or coerced authority can impersonate anyone. Pinning narrows that trust to a single key or a small set of keys, so that an attacker needs the actual private key, not merely a friendly certificate authority.
The idea had a dramatic career in browsers, rose to a standard, and was then abandoned as too dangerous to use at scale. This article explains what certificate pinning is, how it works, and where it still belongs today.
Key takeaways
- Certificate pinning ties a host to one specific key, not to any authority.
- It defeats attacks that rely on a compromised certificate authority.
- Browser pinning (HPKP) was abandoned after costly misconfigurations.
- Mobile apps still pin, using built-in configuration or libraries.
- Backup pins are essential; losing a key can lock everyone out.
What certificate pinning is
Pinning means storing a fingerprint of the expected certificate or public key inside the client, and checking every connection against it. The fingerprint is usually a hash of the public key’s SubjectPublicKeyInfo, the standard encoding of a key, and the client computes the same hash for the key the server presents. If the two match, the connection proceeds; if they do not, it fails, no matter how valid the certificate looks.
The browser version was called HPKP, short for HTTP Public Key Pinning, and it was standardised in 2015. A website could send a Public-Key-Pins header listing the hashes it expected, plus a backup pin and a lifetime, and the browser would remember them and enforce them on later visits. It was a powerful idea, and it lasted only a few years before every major browser removed it.
The removal was about risk, not about cryptography. A site that pinned the wrong key, or lost its private key without a working backup pin, would lock its own users out for the whole lifetime of the pin, and there was no override.
Worse, an attacker who could inject a header could pin a site to a key they controlled, holding it for ransom. Chrome removed HPKP in 2018, Firefox followed, and the standard was abandoned.
Mobile apps never stopped pinning, because their situation is different. An app talks to a small number of servers its developers control, it ships with its pins baked in, and it can be updated when keys rotate. Android supports pinning through its network security configuration, iOS through delegate callbacks and libraries such as TrustKit, and both treat a mismatch as a hard failure.
Our guide to certificate transparency explains the public log system that replaced browser pinning, and our guide to the TLS handshake explains the moment in the connection where pinning is checked.
How certificate pinning works
Setup begins with choosing what to pin. The usual choice is the public key of the leaf certificate, or of an intermediate certificate, hashed with SHA-256 and encoded in base64. Pinning the leaf is the strictest option, while pinning an intermediate survives a leaf rotation, which is the compromise most apps choose.
Backup pins are the safety net, and they are not optional. A backup key is generated, kept offline, and its hash is pinned alongside the live one, so that if the live key is lost or compromised, the site can switch to the backup and users can still connect. Every pinning disaster story in the literature is, at heart, a story about a missing backup pin.
Verification happens during the handshake. After the server presents its certificate chain, the client computes the hash of the presented key and compares it with the stored pins.
The check runs after the ordinary certificate validation, so a connection must pass both: the certificate must be valid, and the key must be one of the pinned ones. Either failure ends the connection.
Rotation is the operational discipline that makes pinning survivable. Before a key expires or is replaced, the new key’s hash is added to the pin set, the app or header is updated, and the old key is kept until the pin lifetime has passed. A site that rotates without this overlap will lock out every client that cached the old pins.
Static pinning is the variant that survived in browsers. Chrome ships with a built-in list of pins for Google’s own properties and a small set of other high-value sites, maintained by the browser vendor rather than by each site. It gives the biggest targets the protection of pinning without handing every website a footgun.

Comparing certificate pinning with other trust mechanisms
Certificate pinning is one of several ways to strengthen trust in a connection, and each was built with a different emphasis. Certificate transparency logs every certificate publicly so mis-issuance can be spotted, DNS-based authentication ties certificates to DNS records, and the ordinary certificate authority system trusts any authority to vouch for any site, and each approach trades strength for safety in a different way.
The table below sets out the main contrasts between the leading approaches.
| Aspect | Certificate pinning | Certificate transparency | Ordinary CA system |
|---|---|---|---|
| Trusts | One pinned key only | Public logs plus CAs | Any trusted authority |
| Stops a rogue CA | Yes, completely | Detects it after the fact | No |
| Misconfiguration risk | High, can lock users out | Low | Low |
| Key rotation | Needs careful overlap | Automatic | Automatic |
| Best for | Mobile apps | Every website | General browsing |
The practical result is that certificate pinning is the right choice for mobile apps with controlled servers, certificate transparency suits every website, and the ordinary authority system remains the default for general browsing.
Where certificate pinning is used
Banking apps are the biggest users. A banking app talks to a handful of servers, and the cost of a compromised authority issuing a fake certificate for the bank is catastrophic, so pinning is standard practice. The app ships with pins for the bank’s keys, and a mismatch means the connection dies rather than risking a customer’s money.
Messaging apps pin for the same reason. An app that carries private conversations cannot afford to trust any authority in the world, and pinning narrows the trust to the keys its own team controls. The pins ship with the app, and they rotate with app updates.
Enterprise mobile device management uses pinning to protect internal services. A company’s internal apps talk to its own servers, and pinning ensures that a device on a hostile network cannot be tricked into talking to an impostor, even if the network presents a valid-looking certificate.
Browsers still pin statically for their own properties. Chrome’s built-in pin list covers Google services and a small number of other high-value sites, and it is updated with the browser itself. It is pinning without the footgun, because the vendor, not each website, maintains the list.
Internet-of-things devices pin to their cloud endpoints. A sensor or a camera that talks to one server for its whole life has no reason to trust the world’s certificate authorities, and pinning its manufacturer’s key is both simpler and safer than carrying a full trust store.
Strengths and limits
The greatest strength of certificate pinning is that it removes the weakest link. A compromised certificate authority is one of the most damaging failures in web security, and pinning makes it irrelevant, because the attacker’s certificate will not match the pin no matter who signed it.
It is also a strength that pinning is simple to understand. The client knows the key it expects, and it checks it, which is a property anyone can audit without understanding the whole certificate ecosystem.
The limits are real, though, and they killed the browser version. Misconfiguration locks out legitimate users, rotation is an operational burden, and a pin set that is too strict becomes a denial-of-service vulnerability against its own site. Pinning is a powerful tool that punishes carelessness, which is why it survives only where the team controlling it is small and disciplined.
Certificate pinning checklist
- Pin the public key, not the whole certificate, so rotation is easier.
- Always generate and pin a backup key kept offline.
- Pin an intermediate, not the leaf, unless you need maximum strictness.
- Overlap pins during rotation; never switch in one step.
- Test pin failure in staging before shipping to users.
- Monitor certificate transparency logs for your own domains.
- Plan an emergency rotation path that does not need an app update.
- Document the pins; a forgotten pin is a future outage.
- Consider static pinning only for properties you fully control.
Frequently asked questions
What is certificate pinning in simple terms?
It is remembering the exact key a server should present and rejecting every other key, even one with a perfectly valid certificate.
What is HPKP?
It was HTTP Public Key Pinning, a 2015 standard that let websites send pins in a header. Browsers removed it after misconfigurations locked users out of their own sites.
Why was HPKP removed from browsers?
Because pinning the wrong key, or losing a key without a backup pin, locked users out for the pin’s lifetime, and attackers could abuse pins to hold sites for ransom.
Is certificate pinning still used?
Yes, mainly in mobile apps, which pin through built-in configuration or libraries, and in browsers as static pin lists for high-value sites.
What should I pin?
Usually the public key of an intermediate certificate, hashed with SHA-256, plus a backup key kept offline, so rotation does not lock anyone out.
When should I use certificate pinning?
When an app talks to a small number of servers you control, and the cost of a rogue certificate outweighs the operational burden of managing pins.
The bottom line
Certificate pinning explained in one line is this: trust one key and no other, and let the connection fail rather than talk to a stranger with a valid-looking badge.
It is the strongest trust mechanism a client can deploy, and the reason browsers took it away from websites is the same reason apps still use it: it punishes mistakes as surely as it stops attackers.
This article is general information about how certificate pinning works, not advice about choosing security measures for a particular system.







