TLS Pinning
TLS certificate pinning embeds the expected certificate public key or hash in the client and rejects all other certificates, preventing man-in-the-middle attacks (including forged certificates issued by legitimate CAs).
Purpose
To prevent man-in-the-middle attacks by adversaries holding legitimate CA certificates (e.g., governments or compromised CAs).
Mechanism
The client preconfigures the SPKI hash (pin) of the server certificate. During the TLS handshake it compares the server certificate with the pin and refuses the connection on mismatch. Types: SPKI pin, certificate-chain pin. Common in mobile apps; browsers rarely pin because certificate rotation is hard.
Use cases
- Mobile app API MITM defense
- IoT device communication
- High-security API clients
- Inter-service communication
Examples
- Input
pin: sha256/SPKI=abc...OutputReject on certificate mismatchPublic key pinning
Common errors
- Expired pins without updates cause connection failures
- Provide backup pins and a rotation policy
Related terms
TLS
TLS (Transport Layer Security) provides encryption, integrity, and authentication at the transport layer; it replaced SSL and underpins HTTPS, SMTPS, and more. GLOSSARY
X.509 Certificate
An X.509 certificate binds a public key to an identity, signed by a CA for verification, containing validity, issuer, subject, and extension fields. GLOSSARY
CA
A CA (Certificate Authority) is a trusted third party that issues digital certificates binding public keys to identities, serving as the trust root of PKI. GLOSSARY