# What Is HPKP (HTTP Public Key Pinning)? Definition and Examples

> HPKP is a deprecated HTTP header, defined in RFC 7469, that told browsers to accept a site only if its chain contained a pinned public key.

Source: https://ssl.sh/glossary/hpkp/
Last updated: 2026-11-10

HPKP (HTTP Public Key Pinning, [RFC 7469](https://www.rfc-editor.org/rfc/rfc7469)) let a site send a Public-Key-Pins header listing SHA-256 hashes of public keys (SPKI pins). For max-age seconds afterwards, the browser rejected any connection whose certificate chain did not include at least one pinned key, even if the certificate was otherwise valid. The RFC required at least one backup pin for a key not in the current chain.

## Why it matters
HPKP is a cautionary tale. A lost key, a forced CA change or a wrong pin could lock users out for the whole max-age with no remote fix, a failure known as "HPKP suicide"; an attacker who briefly controlled a site could even set malicious pins to hold it hostage. Adoption stayed tiny, and HPKP was removed from Chrome in Chrome 72. The problem it addressed, rogue certificates from trusted CAs, is now handled mainly by [Certificate Transparency](https://ssl.sh/glossary/certificate-transparency/) and [CAA](https://ssl.sh/glossary/caa/). Pinning survives mostly inside mobile apps as [certificate pinning](https://ssl.sh/glossary/certificate-pinning/), with the same operational risks.

## Example
Compute a pin, and the header a site would once have sent:

```bash
openssl x509 -in cert.pem -pubkey -noout \
  | openssl pkey -pubin -outform der \
  | openssl dgst -sha256 -binary | openssl enc -base64
```

```text
Public-Key-Pins: pin-sha256="<primary-key-hash>"; pin-sha256="<backup-key-hash>"; max-age=5184000; includeSubDomains
```

Do not deploy this header today.

## Common misconceptions
- **HPKP is the same as HSTS.** HSTS forces HTTPS; HPKP restricted which keys were acceptable. HSTS remains recommended, while HPKP has been removed from Chrome.
- **Pinning the leaf key is safe if you renew carefully.** Renewing with a new key breaks the pin unless a backup pin covers it, which is exactly how sites locked themselves out.
- **Removing the header unlocks users immediately.** Browsers kept the pins until max-age expired.

## Related terms

- [证书锁定](https://ssl.sh/zh/glossary/certificate-pinning/): 证书锁定是客户端侧的一项检查：只有服务器证书链中包含事先配置好的特定证书或公钥时，客户端才接受这次连接。
- [HSTS](https://ssl.sh/zh/glossary/hsts/): HSTS 是一个 HTTP 响应头，告诉浏览器在指定时间内只通过 HTTPS 访问该站点，并且遇到证书错误时不允许用户继续访问。
- [公钥](https://ssl.sh/zh/glossary/public-key/): 公钥是非对称密钥对中可以公开的一半，写在证书里，供他人验证由对应私钥生成的签名。
- [证书透明度](https://ssl.sh/zh/glossary/certificate-transparency/): 证书透明度（CT）是一套公开、只可追加的日志系统，记录所有公开信任的 TLS 证书，让任何人都能审计 CA 签发了什么。
- [密钥轮换](https://ssl.sh/zh/glossary/key-rotation/): 密钥轮换是按计划或在安全事件后，用新生成的密钥替换旧密钥，以限制密钥泄露造成损失的做法。
- [CAA 记录](https://ssl.sh/zh/glossary/caa/): CAA 记录是一种 DNS 记录，用来声明哪些证书颁发机构可以为该域名签发证书，所有公共 CA 签发前都必须检查。
