Certificate Pinning
Security Patterns

Meaning

Certificate pinning binds a client to a specific server certificate or public key. It mitigates man‑in‑the‑middle attacks that exploit compromised or rogue Certificate Authorities. It is used when a TLS connection is established and the client wants to ensure the server presents the expected credential.

Primary Function

Security

Communicative Purpose

Prevents man‑in‑the‑middle attacks by ensuring the server’s certificate matches a known good value.

Pattern

Validate server certificate → compare its fingerprint or public key hash with a stored pin → proceed only if they match

Função primária

Security

Propósito comunicativo

Prevents man‑in‑the‑middle attacks by ensuring the server’s certificate matches a known good value.

Situações de gatilho

Mobile app: connecting to a backend API over HTTPS; Web service: calling a third‑party payment endpoint; IoT device: establishing a TLS channel to a cloud broker.

Contextos

iOS and Android applications, backend services written in Python or Java, embedded firmware networking stacks.

Padrão

Validate server certificate → compare its fingerprint or public key hash with a stored pin → proceed only if they match

Colocados típicos

  • TLS handshake
  • public key pinning
  • SSLContext
  • network security config
  • certificate hash

Substituições comuns

  • pinning by public key instead of full certificate
  • using SHA‑256 fingerprint rather than raw DER
  • configuring pins via app manifest versus code

Erros comuns

Using an outdated pin after certificate renewal → connection failures; Storing pins in plain text within the app bundle → easy extraction by attackers; Ignoring intermediate CA certificates → validation bypass when chain changes

Similar / contraste

Public Key Pinning (focuses on the key, not the whole certificate) vs Certificate Pinning (binds to the full certificate); HSTS (enforces HTTPS) does not verify certificate identity

Interferências

Coming from JavaScript: assuming fetch() can enforce pinning – browsers do not expose pinning APIs; Coming from Go: using InsecureSkipVerify to bypass verification – defeats the purpose of pinning

Família do chunk

  • TLS handshake
  • Public Key Pinning
  • HSTS
  • Certificate Transparency

Nuance

Do not use pinning when certificates rotate frequently, as it causes service outages; Pinning adds negligible runtime overhead but increases maintenance effort; Pins are ineffective if the attacker compromises the private key of the pinned certificate

Efeito pragmático

Ensures that compromised Certificate Authorities cannot be used to impersonate the service, protecting sensitive data in transit.

Dica de memória

Think of pinning like a lock that only opens for a specific key shape, rejecting any other keys even if they look similar.

Nota

Certificate pinning does not replace proper certificate validation; it should be combined with regular CA checks and, optionally, Certificate Transparency monitoring.

Upgrade path

Integrate Certificate Transparency logs to detect unauthorized certificate issuance

Frequência: MediumFormulaicidade: FixedTipo de construção: conceptPrioridade de aquisição: Active recallPrioridade de output: BothTag de espaçamento: Medium-term

Log in to save chunks.