← Glossary

What Is SSL Pinning?

SSL pinning, more accurately certificate pinning, is a client-side check that a TLS server presents a specific expected certificate or public key, in addition to ordinary chain validation. It narrows trust from every certificate authority to a chosen set of keys, at the cost of outage risk when keys change.

Updated:

SSL pinning, also called certificate pinning, restricts a client application to an expected certificate or public key when it connects to a server. A connection can fail the pin check even when its certificate would pass ordinary trust validation. The familiar name refers to modern TLS, not a recommendation to use obsolete SSL protocols. A pin narrows the certificates accepted for a particular host; it should supplement normal certificate and hostname checks. This can resist a mis-issued certificate or an interception proxy trusted by the operating system. It also creates an operational dependency: the server must present something every supported client still recognises.

Certificate Validation and Pin Checks

A standard TLS handshake includes certificate validation: the client checks that the server's certificate is within its validity period, that its name matches the host, that it has not been revoked where that can be checked, and that it chains through intermediates to a trusted root. Pinning adds a step after that. The OWASP Pinning Cheat Sheet describes it as associating a host with its expected X.509 certificate or public key, and where several are acceptable the client holds a pinset; the credential the server advertises must match one element of the set or the connection is rejected.

The pins themselves can be delivered in several ways. Embedding them in the application at build time is the preferred approach, because the developer knows the server's keys in advance. Trust on first use records whatever the server presented the first time and holds it thereafter, which lacks an independently preconfigured pin on the first connection, even if normal TLS validation still applies. Some designs update the pinset over a separate channel so that keys can change without shipping a new client. In every case the check is performed by the client's own code or by platform facilities designed for it; the server cannot make an arbitrary client enforce an application pin.

Public Keys, Certificates and Rotation

What exactly gets pinned shapes how the system behaves when things change.

Pin targetWhat must stay constantTrade-off
Whole leaf certificateThe exact certificate bytesChanges at renewal unless the accepted set is updated
Leaf public keyThe key pair behind the certificateSurvives renewal if the key is reused; needs a backup pin
Intermediate CA keyThe issuing authority's keySurvives leaf changes; Allows otherwise-valid host certificates under that CA
Root CA keyThe root authority's keyWidest tolerance; OWASP advises against it as it trusts all intermediates

Public key pinning is generally more flexible than pinning a certificate, because a certificate can be renewed while the underlying key stays the same, and a key can even be pinned before its certificate is issued. A common representation hashes SubjectPublicKeyInfo, the certificate structure containing the public key and its algorithm information. The exact representation must match the client library's expectations. A backup pin can recognise a planned spare key or a broader issuing authority. That choice changes both recovery options and the set of certificates accepted.

Rotation needs overlap. A release can accept both the current key and a prepared replacement; the server then switches after the relevant client population has that release. Later releases can retire the old pin. Devices that never update remain a problem. For example, a warehouse tablet left on an old app version may stop synchronising when a perfectly valid new certificate arrives. Fresh keys at renewal are compatible with pinning if the replacement is prepared and distributed in time. Keeping a compromised key solely to preserve compatibility defeats the protection.

Application Pinning vs Historical Browser HPKP

There have been two quite different places to pin. Native applications, especially mobile apps, pin inside their own code or configuration, and the developer controls both the client and the server. Browsers briefly had a mechanism of their own: HTTP Public Key Pinning, defined in RFC 7469 in 2015, let a server send a header instructing the browser to remember its public key fingerprints for a period and reject non-matching chains afterwards.

HPKP is now historical. Chrome announced its removal in the deprecations list for version 72, citing very low adoption together with the risk of denial of service and hostile pinning, and mainstream browsers no longer honour the header. The failure modes were the problem: an operator who lost a pinned key locked their own users out for the pin's lifetime, and an attacker who briefly controlled a site could pin a key the owner did not possess. A website should not depend on the old header for protection in current mainstream browsers. This says nothing about an individual application's embedded pins or browser-internal controls; those are different mechanisms.

When Pinning Is Appropriate

Pinning needs a specific threat model and reliable control of both endpoints. A managed native client talking to its own backend may justify it if the team can distribute updates, protect replacement keys and recover from pin failures. An ordinary web page cannot impose equivalent checks on the browser's TLS implementation. Connections to third-party services are a poor fit when the application developer cannot coordinate their certificate changes.

Current OWASP guidance is cautious because outages can outweigh the additional protection. Android also warns about compatibility failures and advises providing a backup key when pinning is used. Those are operational constraints, not reasons to disable ordinary TLS checks. Before adopting pins, establish which attack standard validation does not address and whether the update process can maintain the extra restriction.

A corporate inspection proxy presents another design decision. Allowing its certificate or authority expands trust to that proxy and permits its inspection. Rejecting it may prevent the app from working on that managed network. The application owner must choose and document that trust boundary; an unexplained connection failure is not a workable deployment policy.

Risks and Limits

Pinning raises the cost of one attack, substitution of the server's certificate, and does nothing about others. It does not protect data on a compromised device, where sufficiently privileged attackers may modify application code or bypass the check. Merely adding a CA to a trust store does not necessarily defeat a correctly enforced independent pin. It does not authenticate the user, encrypt data at rest or fix flaws in the API behind the connection. And implementation mistakes are common enough that OWASP advises against writing custom pinning code, preferring well-tested platform or library support.

The dominant practical risk remains availability. A certificate authority that revokes and reissues on short notice, an unusable backup pin, a release that shipped without the new pin, or a forgotten service migrated to a new provider can block affected client versions. Recovery may be possible by presenting a still-accepted certificate, but otherwise requires a trusted update path. Teams that pin should monitor pin failures, keep documented rotation runbooks and rehearse them. A fallback that silently accepts any certificate restores connectivity by removing the intended protection. Recovery should preserve the documented trust policy.

Frequently asked questions

Is pinning the same as normal TLS validation?

No. Standard validation accepts any certificate that chains to a trusted authority and matches the hostname. Pinning adds a further check that the certificate or public key matches one the client already expects, so a technically valid certificate from a different key or authority is rejected.

What happens when a pinned key changes?

Clients that do not accept the replacement reject it, even if normal TLS validation succeeds. An overlapping pinset lets prepared clients accept either key during a planned transition. Older clients and emergency changes remain risks, so rotation must account for devices that update slowly or never reconnect for an update.

Can pinning cause availability problems?

Yes. A valid certificate renewal can still fail an exact-certificate pin, and changing a key can strand clients with an old key pin. Recovery depends on an already trusted replacement or a secure client update. A backup works only if the server can actually present a corresponding acceptable certificate.

Do browsers still support pinning headers?

Current mainstream browsers no longer support the historical HPKP header as a website-controlled protection. Chrome removed it after low adoption and lockout risks. Do not confuse that retired header with native-app pinning or internal certificate restrictions that a particular client may implement.

Should a pinned app allow a corporate inspection proxy?

That is a trust-policy decision, not a harmless compatibility switch. Accepting the proxy allows it to terminate and inspect the connection, while rejecting it may make the app unusable on that network. Document the requirement and trade-off rather than silently bypassing a failed pin check.