HTTP Signatures prove identity in federation without shared secrets
HTTP Signatures use public-key cryptography to verify that a federated message actually came from the server it claims to be from.
In a [[federated]] network, when Instance B receives a message claiming to be from Instance A, how does it verify the claim? There are no shared passwords, no central authority, no OAuth provider. The answer is HTTP Signatures โ a mechanism based on public-key cryptography.
The Mechanism
Every instance generates a keypair. The private key stays secret; the public key is published in the actor document for anyone to read.
When Instance A sends a POST to Instance B’s inbox:
- Select headers to sign: typically
(request-target),host,date,digest, andcontent-type. Thedigestis a SHA-256 hash of the request body, ensuring body integrity. - Create a signing string: concatenate the selected headers into a canonical format.
- Sign the string with the private key (RSA-SHA256), producing a base64-encoded signature.
- Attach a
Signatureheader containing thekeyId(URL to the public key), the list of signed headers, and the signature.
On the receiving side, Instance B:
- Parses the
Signatureheader to extractkeyIdand signed headers - Fetches the public key from the
keyIdURL (cached after first fetch) - Reconstructs the signing string from the actual received headers
- Verifies the signature against the signing string using the public key
- Verifies the
Digestheader matches the body hash - Checks the
Dateheader is within an acceptable window (~12 hours) to prevent replay attacks
Any failure means reject with 401 Unauthorized.
Why This Works
- No shared secrets needed between instances (unlike API keys)
- No central authority needed (unlike OAuth with a central identity provider)
- Each instance manages only its own keypair
- On-demand key discovery: public keys are fetched and cached, so first contact with a new instance costs one extra HTTP call; subsequent interactions are zero-overhead
- Body integrity: the
Digestheader prevents tampering even through proxies
Key Rotation
When rotating keys: generate new keypair, update the actor document, send an Update activity to followers. Remote instances with stale cached keys will fail verification, re-fetch the actor document, get the new key, and retry. This means signature verification failure should trigger one cache-refresh retry before permanent rejection.
Security Considerations
- Replay attacks: prevented by the
Dateheader โ receivers reject requests older than ~12 hours - Actor spoofing: prevented by fetching the public key from the claimed actor’s domain and verifying the
keyIddomain matches theactorfield’s domain - All federation must use HTTPS โ HTTP Signatures protect integrity, but only HTTPS protects confidentiality
Related Concepts
- [[ActivityPub]] โ the protocol that relies on HTTP Signatures for authentication
- [[Federation]] โ the network model where identity verification without central authority is essential