Repository navigation
Description
Description
Let an EdgeZero application present a TLS client certificate (mTLS) on outbound HTTPS requests. The application should reference the certificate by a declared name, and each adapter should resolve that name to the provider's own mechanism. Fastly is the first adapter to implement it. The contract must also fit Cloudflare, Spin and Axum without changes to application code.
The first consumer is Trusted Server, which needs to send Prebid Server OpenRTB auction requests to an endpoint that requires a client certificate (IABTechLab/trusted-server#1650).
Current state
- Main's Fastly proxy builds every dynamic backend with
enable_ssl,sni_hostnameandcheck_certificateand has no client-certificate input (ensure_backend). - PR feat: implement portable outbound HTTP and request lifecycle contracts #275 replaces that path with
OutboundRequestandHttpClient. ItsOutboundRequesthas no TLS client settings. Its Fastly adapter registers backends under a name hashed from aBackendIdentityof host, port, scheme, TLS flag, wire authority and timer settings (backend_name). A client certificate is not part of that identity. - PR feat: implement portable outbound HTTP and request lifecycle contracts #275 already classifies Fastly TLS handshake failures (
TlsCertificateError,TlsAlertReceived,TlsConfigurationError) inerror_detail.rs. A rejected client certificate should surface through those causes.
This work builds on the #275 outbound API. It should not extend the legacy ProxyClient.
How each provider does mTLS
The providers differ in where the certificate lives and when it gets bound to a request. That difference decides the shape of the portable API.
| Provider | Where the cert and key live | How a request uses it | Chosen per request? | Local dev |
|---|---|---|---|---|
| Fastly Compute | Key in a Secret Store, passed as a Secret handle. The cert is plain PEM and can live anywhere. |
BackendBuilder::provide_client_certificate(pem_certificate: impl ToString, pem_key: Secret) on a dynamic backend. Fastly asks callers not to unpack the key with Secret::plaintext. |
Yes, at backend registration | Viceroy 0.21.0 (our pinned version) honors client certs on dynamic backends and resolves the key from its local secret stores (component/backend.rs) |
| Cloudflare Workers | Uploaded with wrangler mtls-certificate upload, then bound in Wrangler config as [[mtls_certificates]] binding = "X" certificate_id = "..." |
env.X.fetch(...). The binding is a Fetcher that always presents its certificate (docs) |
No. One binding per certificate, fixed at deploy time | Not available in wrangler dev without --remote (workers-sdk#6067) |
| Spin | [[client_tls]] in runtime config with component_ids, hosts, client_cert_file, client_private_key_file, ca_roots_file (source) |
The host picks it by component and destination host. The guest never sees it. | No, configured by host | Yes |
| Axum | Files or env | reqwest::Identity::from_pem on a dedicated reqwest::Client |
Yes, but each identity needs its own client | Yes |
Fastly also supports client certificates on static backends (ssl_client_cert / ssl_client_key in service config). We should not rely on that. It puts the private key in service configuration instead of a Secret Store, and both EdgeZero and Trusted Server use dynamic backends.
Two of the four providers attach the certificate outside the application, at deploy or runtime-config time. If the portable API accepted raw PEM on the request, it could not run on Cloudflare at all, and on Fastly it would pull the private key into guest memory, which Fastly advises against. So the application should refer to a client identity by name, and each adapter should resolve that name in its own way.
Proposed design
The full design is in the spec at docs/superpowers/specs/2026-11-23-outbound-client-identity-design.md on feat/523-outbound-client-identity. Summary:
1. The manifest declares names only
[capabilities.outbound.client-identities.prebid-server]
secret-store = "default" # optional; defaults to the [stores.secrets] default
config-store = "app_config" # optional; defaults to the [stores.config] defaultThe manifest holds the identity name and its logical stores, and nothing else. Hosts, certificate and key are bound at runtime. That keeps operator configuration out of the compiled binary, which Trusted Server's release attestation requires (R-CONFIG). A new outbound-client-identity capability lets apps require support.
2. Requests select an identity by name
OutboundRequest::client_identity(ClientIdentityName) sets the identity on one request. The request never carries PEM bytes or key material. Before any I/O, on the initial request and on every redirect hop:
- the name must be declared
- the URI must be
https - the adapter must support identities
- the request's scheme, host and port must exactly match one of the identity's runtime hosts
Core owns the host parsing and matching, so every adapter enforces the same rules.
3. Fastly binding
Only the key needs the Secret Store. Fastly allows 5 Secret Store reads per Compute request by default, and the application shares that budget, so the binding spends one:
| Store | Entry | Read as |
|---|---|---|
| Config Store | <name>.certificate |
PEM chain, leaf first, bounded read, at most 8,000 characters |
| Config Store | <name>.hosts |
Exact HTTPS origins, one per line. Each must be allowed by [capabilities.outbound].hosts |
| Secret Store | <name>.private-key |
Secret handle only, never plaintext |
- The adapter reads the binding at most once per identity per inbound request. Every hop still checks its destination against the hosts list.
- It calls
provide_client_certificate(cert, key). - The backend name includes the identity name and the SHA-256 of the whole certificate chain, under a new
ez_b31v2_prefix. So no identity, different identities, and any change to the chain never share a backend. - Identity requests always bypass Fastly's response cache, whose default key is the URL and
Hostwithout the backend.
4. Other adapters
Cloudflare, Spin and Axum reject identity requests before I/O and report the capability as unsupported. Follow-up issues add their bindings: a [[mtls_certificates]] binding on Cloudflare, generated [[client_tls]] on Spin, and one reqwest::Client per identity on Axum.
Relationship to existing TLS options
#81 owns server-side TLS controls: certificate verification, SNI, the development opt-out and a custom CA for verifying the origin's server certificate (Fastly ca_certificate, Spin ca_roots_file). The client certificate and the server certificate are independent. The first consumer's origin keeps a public server certificate (an ACM certificate on an AWS ALB), so this issue does not depend on #81.
Certificate requirements
Document these for operators:
- The private key must be unencrypted PEM. Fastly's static-backend docs say so explicitly, and dynamic backends take the same PEM input.
- The leaf certificate needs the
clientAuthextended key usage. - The certificate entry may hold the leaf plus intermediates.
- A private CA issues the certificate. Public CAs are removing the
clientAuthEKU under Chrome root program rules. Let's Encrypt stopped on July 8, 2026, and DigiCert's last date is March 1, 2027.
Out of scope
- Inbound (downstream) mTLS, meaning client certificates presented to EdgeZero
- Cloudflare, Spin and Axum implementations beyond explicit
Unsupportedbehavior (follow-up issues) - Issuing certificates, rotation automation, or provisioning of Cloudflare and Spin certificates
Decisions
- The certificate and hosts list live in the Config Store, and only the key in the Secret Store, so each identity spends one Secret Store read per inbound request.
- The CLI validates the manifest only. Viceroy secret-store setup is documented, not generated.
hoststakes exact HTTPS origins only, with no wildcards.
Done when
- The design spec is reviewed and merged.
-
OutboundRequestcan carry a validated client identity name and never carries key material. - A request whose origin is not in the identity's runtime hosts, including after a redirect, fails before I/O.
- The Fastly adapter presents the declared certificate through
provide_client_certificatewith the key passed as a Secret Store handle. - The Fastly backend name includes the identity and certificate fingerprint. Requests with no certificate, different certificates or a rotated certificate never share a pooled backend.
- An undeclared identity, missing secrets and unsupported adapters fail before I/O with documented errors. No adapter silently sends without the certificate.
- A Viceroy contract test against a local origin that requires client auth shows that the handshake succeeds with the identity and fails without it.
- Docs explain how to declare, provision and rotate an identity on Fastly.
- Follow-up issues exist for Cloudflare, Spin and Axum.
Related
- Parent: Dynamic Backend Abstraction #79 (dynamic backend abstraction). Sibling: Backend TLS options #81 (backend TLS options).
- Builds on feat: implement portable outbound HTTP and request lifecycle contracts #275 / Implement portable outbound HTTP and request lifecycle contracts #436 (portable outbound HTTP).
- Consumer: Present a client certificate on auction provider OpenRTB requests (mTLS) trusted-server#1650 (Prebid Server mTLS), which in turn depends on Cut Trusted Server over to EdgeZero PR 275 trusted-server#1507 (cutover to feat: implement portable outbound HTTP and request lifecycle contracts #275).
- References: Fastly origin mTLS example, Cloudflare Workers mTLS, Spin v2.7.0
client_tls.
Activity
[-]Support mTLS on Fastly backends[/-][+]Portable outbound mTLS client identity, implemented on Fastly first[/+]ChristianPavilonis commentedon Nov 24, 2026
Implementation: #524. Follow-ups for the other adapters: #525 (Cloudflare), #526 (Spin), #527 (Axum).
Remove PR #522 and PR #524 from rc/identity