HTTP Message Signatures and API Integrity Explained

Updated on
12 min read

HTTP Message Signatures provide a standard way to prove that selected parts of an HTTP request or response were created by a party holding a signing key. They are useful for API clients, gateways, payment systems, and service-to-service calls that must preserve message integrity after traffic crosses a proxy or TLS-terminating load balancer. This guide explains the mechanism defined by RFC 9421, how it differs from TLS and bearer-token authentication, and how to deploy it without treating a valid signature as a complete authorization decision.

What Are HTTP Message Signatures?

An HTTP Message Signature is a digital signature or keyed message authentication code over one or more components of an HTTP message. A signer chooses the fields and derived values that matter, constructs a deterministic signature base, signs that byte sequence, and sends the signature metadata with the message. A verifier reconstructs the same base from the received message and checks it with trusted key material.

The mechanism is detached: the original request or response remains an ordinary HTTP message, while Signature-Input describes what was signed and Signature carries the resulting value. The specification supports asymmetric digital signatures and symmetric MACs. Asymmetric keys are usually easier to distribute when many independent verifiers need to validate requests without receiving a shared signing secret.

HTTP Message Signatures are an HTTP-layer integrity control, not a replacement for encryption. HTTP Semantics, RFC 9110, defines HTTP as an intermediary-friendly protocol, and that flexibility is exactly why a message can pass through several independent connections. The IETF HTTP Working Group maintains the standards work around HTTP extensions, including the rules that make signed components interoperable.

Why HTTP Message Signatures Exist

TLS protects bytes exchanged over one TLS connection. In a common deployment, a client connects to a CDN or API gateway, the gateway terminates TLS, and the gateway opens another connection to the origin. Each connection can be secure while the application still lacks proof that a particular client created the request.

Bearer authentication has a different boundary. An access token can establish that a request presents a credential with a particular scope, but it does not automatically bind the credential to the method, URI, headers, or body that the service receives. A stolen bearer token may be replayed with a different request until it expires or is revoked.

Object signatures such as JSON Web Signature (JWS) can protect a JSON object, but applying them directly to HTTP often duplicates headers, the target URI, or a body digest inside a separate object. The receiver then has to check that the duplicated values match the HTTP message. HTTP Message Signatures instead define a common way to select and canonicalize the HTTP components themselves.

The result is useful when a request crosses a TLS-terminating intermediary, a service needs proof that a partner created it, a gateway must preserve selected client-authored values, or a response must remain attributable to its producer. It complements OAuth, mTLS, and other authentication mechanisms rather than replacing them.

The signature does not make an untrusted key trusted, grant permission, encrypt content, or prevent every replay.

How HTTP Message Signatures Work

The signing and verification process has four main stages:

  1. The application chooses an ordered list of covered components and signature parameters.
  2. The signer obtains each component value from the HTTP message, applies the specification’s canonicalization rules, and builds the signature base.
  3. A cryptographic algorithm signs the base. The result is encoded in the Signature field, while Signature-Input communicates the covered components and parameters.
  4. The verifier parses the fields, reconstructs the same base from its view of the message, validates the signature with a trusted key, and applies freshness and policy checks.

Covered components and canonicalization

Components can be ordinary HTTP fields, such as host, content-type, or content-digest, and derived components identified by names such as @method, @target-uri, @authority, @request-target, and @status. The signer should cover the values that affect the operation being authorized, rather than signing every field indiscriminately.

The order matters. A signature input such as:

("@method" "@target-uri" "host" "content-digest")

is not interchangeable with the same names in a different order. The verifier uses the declared order when reconstructing the signature base. Field names are processed according to HTTP rules, while derived components are calculated from the request or response representation available at the verification boundary.

Canonicalization lets a signature survive transformations that HTTP permits, but it does not make arbitrary transformations safe. If a proxy changes a signed host, method, URI, or content digest, reconstruction should fail. An uncovered value can change without invalidating the signature, so the verifier must reject signatures that omit components required by endpoint policy.

Signature-Input and Signature fields

The Signature-Input field names a signature and describes its covered components and parameters. The Signature field uses the same label to carry the encoded cryptographic output. A simplified request layout looks like this:

POST /payments HTTP/1.1
Host: api.example.test
Content-Type: application/json
Content-Digest: sha-256=:BASE64_BODY_DIGEST:
Signature-Input: sig1=("@method" "@target-uri" "host" "content-digest");created=SIGNING_TIME;expires=EXPIRY_TIME;keyid="client-key";alg="ed25519"
Signature: sig1=:BASE64_SIGNATURE:

The values in this example are placeholders for a real implementation. created and expires establish a validity window, keyid selects verification key material, and alg identifies the configured signing algorithm. The signature itself covers the signature base, which includes the covered components and the @signature-params value; it is not simply a signature over the visible Signature header.

The body is not automatically covered merely because a request has a signature. A sender can include a digest field and sign that field, allowing the verifier to check that the body it reads has the expected digest. A content digest is a separate concern from the HTTP Message Signature and should be computed and validated with a current digest specification such as RFC 9530.

Key discovery and trust

keyid is an identifier, not a certificate or proof that a key is trusted. The verifier needs a local mapping, configured key directory, certificate chain, or another authenticated distribution mechanism. Never fetch an arbitrary key from a request-controlled URL and immediately trust it.

The key policy should bind an identity to an allowed algorithm and request capabilities. Define rotation too: overlap old and new public keys, publish the new key under a new identifier, and remove the old key after messages signed with the old one can no longer be accepted.

The protocol can use asymmetric signatures or keyed MACs. Asymmetric signatures are a practical default for partner and multi-service systems because verifiers only need public keys. A MAC can be appropriate inside a tightly controlled trust domain, but every verifier that has the shared key can also create valid signatures. That makes attribution and compromise containment more difficult.

Freshness and replay

A valid signature proves that the signer created the covered representation at some point; it does not prove that the message is being seen for the first time. Replay protection requires application policy. Check created and expires against a trusted clock, allow only a deliberately small clock skew, and reject signatures outside the accepted window.

For operations where replay is harmful, add a signed nonce or unique request identifier and record it until expiry. An idempotency key can control duplicate business operations, but it is not a substitute for authentication. Require a nonce for methods or endpoints that need it instead of assuming timestamps are enough.

Components and Design Choices

Component Purpose Important design question
Covered component list Selects fields and derived values that the signature binds Which method, URI, identity, routing, and body metadata affect authorization?
Signature base Canonical byte sequence signed by both parties Do every signer and verifier use the same HTTP representation?
Signature-Input Communicates covered components and signature parameters Are created, expires, keyid, and algorithm policy present and bounded?
Signature Carries the cryptographic output under a signature label Is the value decoded and verified by a maintained implementation?
Key registry Maps keyid to trusted verification material and identity How are keys discovered, rotated, revoked, and audited?
Freshness controls Limits the time and reuse of a valid message Are clock skew, nonce storage, and idempotency requirements explicit?

A useful policy distinguishes signer-controlled values from gateway-added values. A payment API may require the client to sign the method, target URI, host, body digest, and request identifier. A gateway can add tracing headers after verification, provided downstream services do not treat them as client claims.

Real-World Use Cases

Partner APIs can require signed requests from merchants, banks, or logistics providers. The partner’s public key can be registered out of band, and the API can reject a request whose URI, amount-related headers, or body digest differs from what the partner signed.

Payment and financial messages often need stronger binding than a bearer token provides. A signed idempotency key, target URI, and content digest can help a receiving service distinguish a legitimate request from a modified or replayed one. This still requires business-level duplicate detection and authorization.

Service meshes and API gateways can preserve an upstream identity across TLS boundaries. A gateway verifies the client signature before routing and may issue a new downstream signature after applying its own policy. This is more explicit than assuming that every internal network hop is trusted.

Webhooks and callbacks benefit from receiver-side verification. The sender signs a timestamp, destination, and body digest; the receiver validates the key and freshness before parsing the event. A webhook consumer should still enforce event ordering, idempotency, and authorization for the referenced resource.

Getting Started with HTTP Message Signatures

Start with a threat model and component policy before generating keys. Decide which actors sign, which services verify, which fields may change, and how long a message remains valid. Use a maintained RFC 9421 library and interoperability vectors rather than inventing a signature base or parser.

For a local asymmetric-key setup, generate a signing key and export its public key. Keep the private key outside the repository and restrict its permissions:

openssl genpkey -algorithm Ed25519 -out client-signing-key.pem
openssl pkey -in client-signing-key.pem -pubout -out client-signing-key.pub.pem
chmod 600 client-signing-key.pem

Register the public key in the verifier’s trusted key store under a stable identifier such as client-key. Production signers should load private keys from a secret manager or hardware-backed service. Reject unknown identifiers, unsupported algorithms, missing required components, malformed fields, and signatures outside the accepted time window.

Use a library to create the signature fields. The implementation flow should resemble the following:

covered = ["@method", "@target-uri", "host", "content-digest", "x-request-id"]
created = current_unix_time()
expires = created + short_validity_window
signature_base = build_rfc9421_signature_base(request, covered, created, expires, keyid)
signature_bytes = sign_ed25519(private_key, signature_base)
send(Signature-Input, Signature)

For a body-bearing request, calculate the digest from the exact bytes sent, include that field in the covered list, and avoid middleware that rewrites the body after signing. The receiver should calculate its own digest before accepting the signature.

Test positive and negative cases at the API boundary:

# Observe the request and response headers while testing a verifier.
curl --verbose \
  -H 'Content-Type: application/json' \
  -H 'Content-Digest: sha-256=:BASE64_BODY_DIGEST:' \
  -H 'Signature-Input: sig1=("@method" "@target-uri" "host" "content-digest");created=SIGNING_TIME;expires=EXPIRY_TIME;keyid="client-key";alg="ed25519"' \
  -H 'Signature: sig1=:BASE64_SIGNATURE:' \
  --data '{"amount":100,"currency":"USD"}' \
  https://api.example.test/payments

Replace the placeholders with fields generated by a conforming implementation. Change one input at a time in tests: method, path, host, signed header, body, key identifier, algorithm, timestamp, and nonce. Reject each unauthorized change and accept an unchanged message within policy. Also test a TLS-terminating gateway that forwards the request.

Log verification outcomes without private keys or complete sensitive bodies. Record the signature label, key identifier, endpoint, rejection category, and clock or nonce result. Metrics for unknown keys, expired signatures, invalid bases, and repeated nonces make rollout problems visible.

Common Misconceptions

“TLS makes HTTP Message Signatures unnecessary.”

TLS remains essential for confidentiality, endpoint authentication, and protection between each pair of network peers. A message signature adds an application-level proof that can survive selected TLS-terminating intermediaries. It addresses a different trust boundary.

“A valid signature means the request is authorized.”

The signature validates possession of a trusted key and integrity of the covered components. Authorization still depends on the key’s identity, endpoint policy, token scopes, resource ownership, rate limits, and business rules. A compromised but correctly signed client request can still be unauthorized.

“Signing one header protects the whole request.”

Only the declared components are covered. An unsigned path, body digest, or application header can be changed without invalidating the signature. Choose the component list based on what the operation means, and explicitly reject signatures that omit required components.

“Timestamps alone prevent replay.”

Timestamps narrow the replay window but do not stop an attacker from sending the same message repeatedly during that window. Use nonces, request identifiers, and idempotency controls where duplicate execution has consequences.

Changelog

  • 2026-12-05: First published.
TBO Editorial

About the Author

TBO Editorial writes about the latest updates about products and services related to Technology, Business, Finance & Lifestyle. Do get in touch if you want to share any useful article with our community.