Skip to content

Present a client certificate on auction providers that set mtls - #1667

Open
ChristianPavilonis wants to merge 10 commits into
baseline/aws-examples-20261110from
feat/1650-auction-provider-mtls
Open

ChristianPavilonis wants to merge 10 commits into
baseline/aws-examples-20261110from
feat/1650-auction-provider-mtls

Conversation

@ChristianPavilonis

@ChristianPavilonis ChristianPavilonis commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • An auction provider with mtls = true presents a TLS client certificate, the auction-providers identity, on its OpenRTB requests. On Fastly, EdgeZero takes the chain and the allowed hosts from the Config Store and the key from the Secret Store. Axum, Cloudflare and Spin refuse such a config at startup and in ts config push/diff.
  • The self-hosted PBS AWS example can now require that certificate at its ALBs, per region and off by default, alongside the existing CIDR allowlist. Includes a development certificate script.
  • Moves EdgeZero to v0.0.12-rc-identity.202611.1, which adds outbound client identities (Add outbound mTLS client identities, implemented on Fastly edgezero#524).

Stacked on #1540.

Changes

File Change
Cargo.toml, Cargo.lock, crates/trusted-server-adapter-axum/Cargo.toml EdgeZero pinned to v0.0.12-rc-identity.202611.1. No source changes needed.
edgezero.toml Declares the auction-providers client identity and lists outbound-client-identity as optional
crates/trusted-server-core/build.rs, src/edgezero_manifest.rs Bakes edgezero.toml as JSON, as EdgeZero's app! does, for adapters that implement Hooks by hand
crates/trusted-server-adapter-fastly/src/app.rs Hooks::manifest() returns the baked manifest, so EdgeZero builds the identity policy. Without it every identity request fails as undeclared.
crates/trusted-server-core/src/auction/plan.rs ProviderConfig.mtls (default false, omitted when false); ProviderPlan.client_identity; https required; mtls joins the Fastly backend-bound tuple; reject_auction_mtls
crates/trusted-server-core/src/auction/provider.rs Sets the identity on the provider's OutboundRequest
crates/trusted-server-core/src/outbound.rs outbound_error attaches the identity name and reason, since the EdgeError itself is attached opaquely
crates/trusted-server-adapter-{axum,cloudflare,spin}/src/app.rs Refuse to start when any provider sets mtls
crates/trusted-server-cli/src/checked_app_config.rs ts config push/diff for non-Fastly adapters reject mtls
crates/trusted-server-core/src/test_support/scripted_client.rs, test_support.rs Records the request's identity; client with the manifest's identities; mtls provider fixture
crates/trusted-server-integration-tests/ Viceroy cases against a mock PBS that requires client certificates
deploy/pbs-example/, .github/workflows/pbs-example.yml Optional trust store and verify mode, connection logs, tests, dev certificate script, README/RUNBOOK/DEPLOYMENT_PLAN
docs/guide/*, trusted-server.example.toml, fastly.toml Provider mTLS guide section, configuration and error references, examples
.claude/skills/planning-prebid-aws/references/terraform.md Offers the mTLS option
docs/superpowers/{specs,plans}/2026-11-24-auction-provider-mtls* Spec and plan

Things worth a reviewer's attention:

  • Failure handling. When EdgeZero refuses the identity (an entry missing or invalid, or the origin not in the hosts list), only that provider fails, as transport with no bids, and the warning names the identity and the reason, such as private key is missing. A key that does not match the certificate fails later: launch_failed if Fastly rejects the backend registration (if every routed provider fails to launch, direct /auction returns 502), or transport if the handshake fails. Which of the two production Fastly does is for the staging run. In every case the request is never retried without the certificate.
  • Rollout order. ProviderConfig rejects unknown fields and Fastly loads the config before the app, so a config with mtls breaks every request an older binary serves. Deploy this version first, then push mtls; roll back in reverse. The guide, spec and RUNBOOK say so.
  • Rotation order matters. Write the key first, then the chain. EdgeZero names a backend after the chain, so writing the chain first can leave a sandbox with a mismatched backend until it is recycled. The guide and RUNBOOK say so.
  • Privacy. The certificate identifies the deployment, not a user, and request bodies, consent and forwarded headers do not change. An ALB in verify mode passes certificate details to PBS in X-Amzn-Mtls-Clientcert-* headers, and connection logs record the subject, serial and source IP. The guide asks for a service subject without personal information.
  • Secret Store budget. Each cold backend registration reads the key once. With one PBS endpoint that is one read per auction. It is documented and will be measured in staging; there is no startup cap.
  • Terraform. The listener always renders mutual_authentication (off when unset), and the load balancer always renders connection_logs, because provider 6.64.0 keeps a removed block's setting. The trust store uses create_before_destroy, so the listener is switched off before the trust store is deleted.

Closes

Closes #1650

GitHub closes issues only for PRs into the default branch, so #1650 will be closed by hand when this reaches main. The staging run against a real ALB happens after merge and is recorded on #1650.

Spec

Spec: docs/superpowers/specs/2026-11-24-auction-provider-mtls-design.md, with its review log. Plan: docs/superpowers/plans/2026-11-24-auction-provider-mtls.md.

Test plan

  • cargo test-fastly (4,180 passed) and cargo test-fastly-reuse on stock Viceroy 0.21.0
  • cargo test-axum, cargo test-cloudflare, cargo test-spin, cargo check-cloudflare, cargo check-spin
  • cargo test -p trusted-server-core --test template_build_digest, cargo test -p trusted-server-cli (host target)
  • cargo clippy-fastly, clippy-axum, clippy-cloudflare, clippy-cloudflare-wasm, clippy-spin-native, clippy-spin-wasm, clippy-cli, and clippy for the integration-tests crate
  • cargo fmt --all -- --check
  • Docs: npm run format, npm run lint, npm run build, and Prettier for Markdown outside docs/
  • ts dev lint domains --changed-vs the stack base
  • WASM build: cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1
  • Viceroy cases on stock Viceroy 0.21.0: bids with the certificate; handshake rejected without it; missing key fails before connecting and logs the reason once; a plain bidder keeps its bid each time
  • ./scripts/integration-tests.sh: 81 passed in the first run. The 15 Cloudflare cases failed only because the Workers bundle was not built and, without CI, wrangler used the local wrangler.toml. After build.sh and with CI=1, all 20 Cloudflare cases and test_all_combinations passed.
  • PBS example: terraform fmt, readonly init, validate and both mocked suites (root 8, regional 11, including verify on to off), both Node tests, lock files unchanged
  • After merge: staging run against a real PBS ALB in verify mode, recorded on Present a client certificate on auction provider OpenRTB requests (mTLS) #1650

Checklist

  • Feature PRs: spec linked above, ending in a review log of two or more agent review rounds
  • Changes follow AGENTS.md conventions
  • No unwrap() in production code — use expect("should ...")
  • Uses log macros (not println!)
  • New code has tests
  • No secrets or credentials committed (test certificates are generated at runtime; the dev script writes to an ignored directory)

Pin every EdgeZero dependency to v0.0.12-rc-identity.202611.1, which adds
outbound client identities (edgezero#524) on top of the portable record
providers (edgezero#522). Trusted Server builds and passes its suites
against the tag without source changes. The lockfile also re-resolves a
few transitive dependencies that EdgeZero's new crates share.
An auction provider with `mtls = true` now presents the
`auction-providers` client identity on its OpenRTB requests. The
identity is declared in edgezero.toml and bound to the default config
and secret stores, and the Fastly app returns the baked manifest from
`Hooks::manifest` so EdgeZero builds its identity policy.

- `ProviderConfig.mtls` defaults to false and is omitted when false.
  Plan compilation rejects it with a non-https endpoint, and the Fastly
  backend bound counts it as its own backend.
- Axum, Cloudflare and Spin refuse to start with an mtls provider, and
  `ts config push` and `diff` refuse such a config for those adapters.
- A refused identity is that provider's transport failure, with no
  retry without the certificate. `outbound_error` now attaches the
  identity name and reason, so the auction log says why.
…eroy

A loopback mock PBS requires a certificate from its own client CA. A
prebid-server provider with mtls gets its bid through, the same
provider without mtls fails the handshake, and a missing key fails
before any connection with the identity name and reason in the log. A
plain loopback bidder keeps its bid in every case.
Each region can require a client certificate at its HTTPS listener by
setting a CA bundle bucket and key. The listener keeps its ACM server
certificate and the CIDR allowlist stays. Optional per-region buckets
enable ALB connection logs.

The listener always renders `mutual_authentication`, with mode off when
the inputs are unset, and the load balancer always renders
`connection_logs`, because the AWS provider keeps a removed block's
setting. The trust store uses create_before_destroy so Terraform turns
the listener off before deleting the store.

Adds a bash and openssl development certificate script with a Node
test, and documents CA ownership, rollout one region at a time,
key-first rotation, CA rotation and rollback in the README, RUNBOOK and
DEPLOYMENT_PLAN.
Adds a Provider mTLS section to the auction orchestration guide: the
setting, certificate ownership and the offline CA flow, the three Fastly
store entries, the Secret Store read budget, key-first rotation,
rollback, and troubleshooting by the logged reason. Adds the field to
the configuration reference and example config, the new errors to the
error reference, a pointer from the Prebid guide, and commented local
entries to fastly.toml and the Viceroy template.
@ChristianPavilonis ChristianPavilonis self-assigned this Nov 24, 2026
…ero d063a8e7

Brings Aram's identity integration chain merge-forward and b181544 (Accept
any Fastly EC store link name at startup).

EdgeZero moves from tag v0.0.12-rc-identity.202611.1 to rc/identity
d063a8e7, which contains that tag (client identities) and the Fastly SDK
0.13.3 upgrade. error-reference.md keeps both the base's wording and this
PR's client-identity hint.
Rewriting the auction-providers key and chain in place fails every mtls
auction until both writes reach a POP: the chain comes from the Config Store
on each request, the key from the Secret Store whenever a backend registers,
and the stores propagate independently. Staging measured about three minutes
of failures for a key-first rotation.

Declare two client identities, auction-providers-blue and
auction-providers-green, and select one with [auction] mtls_slot (default
blue, omitted from serialized configs). An operator fills the idle slot, waits
for it to propagate, then pushes the slot switch; every request reads one
complete pair or the other, so no auction pairs a new key with an old chain.

- MtlsSlot in the auction plan and AuctionConfig, threaded into
  compile_client_identity
- edgezero.toml declares both identities
- Viceroy case: green slot alone bids with mtls_slot = green
- Guide, configuration and error references, PBS runbook, example configs and
  the design spec describe slot rotation
ChristianPavilonis added a commit that referenced this pull request Nov 25, 2026
… providers that set mtls

Source: feat/1650-auction-provider-mtls at eaa2b3e.

@prk-Jr prk-Jr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Adds per-provider mtls = true so planned auction providers present an EdgeZero client identity (two rotation slots, auction-providers-blue/-green) on Fastly, with Axum/Cloudflare/Spin and ts config push/diff for those adapters failing closed, plus optional ALB verify mode in the PBS AWS example. The runtime design is sound: the chain and hosts live in the Config Store and the key only in the Secret Store, the identity is set only on mtls providers, EdgeZero's per-identity hosts list keeps the certificate off other origins, refusals fail just that provider as transport with no retry without the certificate, the diagnostic attachment carries the identity name and reason but no PEM, and server certificate verification is unchanged. One CI gate is red because of the example config, and one ordering-sensitive doc step lost its list item.

2 of the inline comments below carry a one-click GitHub suggestion. Use Commit suggestion (or Add suggestion to batch) to apply them.

Blocking

🔧 wrench

  • mtls_slot comment block breaks the template-cache harness, so the cargo test job fails — see inline at trusted-server.example.toml:601

Non-blocking

⛏ nitpick

  • Rollout step 4 is merged into the following paragraph — see inline at docs/guide/auction-orchestration.md:978
  • Doc comment still names the single pre-slot auction-providers identity — see inline at crates/trusted-server-adapter-fastly/src/app.rs:1794

Cross-cutting / body-level findings

  • 📝 PR description predates the slot rotation commit. The summary, the plan.rs row and the rotation-order bullet still describe one auction-providers identity with an in-place key-then-chain rewrite. The head commit replaces that with blue/green slots and a guide that says never to rewrite the active slot in place. Worth refreshing so the merge commit and reviewers of #1674 see the current design.

CI Status

  • cargo test: FAIL (introduced here; passes on the base commit. scripts/template-cache-local-test.sh esi exits with expected one auction timeout replacement target, see the inline comment)
  • local-provider-image: FAIL (pre-existing; the base commit afc4f5d fails the same job with invalid-envelope must not listen, unrelated to this PR)
  • cargo fmt: PASS
  • cargo test (axum native): PASS
  • cargo test (cross-adapter parity): PASS
  • cargo test (ts CLI, native) (ubuntu-latest): PASS
  • cargo test (ts CLI, native) (macos-latest): PASS
  • cargo check (cloudflare native + wasm32-unknown-unknown): PASS
  • cargo check/build/test (spin native + wasm32-wasip1): PASS
  • integration tests: PASS
  • integration tests (Fastly EC lifecycle): PASS
  • browser integration tests: PASS
  • HTML EOF runtime (Fastly): PASS
  • health-startup (axum / cloudflare / fastly / spin): PASS
  • worker-deadlines (cloudflare / spin): PASS
  • PBS Terraform and Compose checks: PASS
  • ts dev lint domains (changed lines): PASS
  • vitest, format-typescript, format-docs: PASS
  • Native provider acceptance script, Fastly response diff script, release scripts, docs-proposal scripts, CI Node pin guard, CLAUDE.md symlink guard: PASS
  • prepare integration artifacts, record-provider-image, stock-celld-records, trace runtime and browser acceptance: PASS

Comment on lines +601 to 606
# Client identity slot that providers with `mtls = true` present: "blue"
# (default) or "green". Rotate by provisioning the idle slot's
# auction-providers-<slot>.* entries, waiting for them to propagate, then
# switching this. Binaries older than this setting reject "green".
# mtls_slot = "blue"
timeout_ms = 2000

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 wrench: This comment block sits between sanitize_creatives = false and timeout_ms = 2000, and the cargo test CI job runs scripts/template-cache-local-test.sh, which rewrites the example config with replace_once(s, 'sanitize_creatives = false\ntimeout_ms = 2000', ...). The literal no longer occurs, so the harness exits before starting the server:

==> Generating stub config (mode: esi)
expected one auction timeout replacement target

That is the cargo test failure on this head; the same job passes on the base commit. I reproduced it by running the harness's config generator against this file (exit 1) and against the change below (generates the config).

Moving the comment below timeout_ms keeps the docs and restores the anchor:

Suggested change
# Client identity slot that providers with `mtls = true` present: "blue"
# (default) or "green". Rotate by provisioning the idle slot's
# auction-providers-<slot>.* entries, waiting for them to propagate, then
# switching this. Binaries older than this setting reject "green".
# mtls_slot = "blue"
timeout_ms = 2000
timeout_ms = 2000
# Client identity slot that providers with `mtls = true` present: "blue"
# (default) or "green". Rotate by provisioning the idle slot's
# auction-providers-<slot>.* entries, waiting for them to propagate, then
# switching this. Binaries older than this setting reject "green".
# mtls_slot = "blue"

Comment on lines +972 to +979
3. Push the config with `mtls = true`. With `reusable-sandbox`, a running
sandbox keeps its old settings until it is recycled, so allow for that
before the next step.

`mtls_slot = "green"` follows the same rule: versions without the field reject
it, so deploy a version that supports it before the first push that sets it.
The default `blue` is omitted from the stored config. 4. Turn on client verification at the provider, and confirm auctions succeed.
The PBS AWS example does this one region at a time.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏ nitpick: The mtls_slot note was placed between list items 3 and 4, so Prettier folded step 4 into the paragraph and it renders as ...omitted from the stored config. 4. Turn on client verification.... This list exists because "the order matters", so step 4 should stay a numbered step. Putting the note after the list fixes it (Prettier check passes on the result):

Suggested change
3. Push the config with `mtls = true`. With `reusable-sandbox`, a running
sandbox keeps its old settings until it is recycled, so allow for that
before the next step.
`mtls_slot = "green"` follows the same rule: versions without the field reject
it, so deploy a version that supports it before the first push that sets it.
The default `blue` is omitted from the stored config. 4. Turn on client verification at the provider, and confirm auctions succeed.
The PBS AWS example does this one region at a time.
3. Push the config with `mtls = true`. With `reusable-sandbox`, a running
sandbox keeps its old settings until it is recycled, so allow for that
before the next step.
4. Turn on client verification at the provider, and confirm auctions succeed.
The PBS AWS example does this one region at a time.
`mtls_slot = "green"` follows the same rule: versions without the field reject
it, so deploy a version that supports it before the first push that sets it.
The default `blue` is omitted from the stored config.

/// Returns the repository's `edgezero.toml`, baked at build time.
///
/// [`App::from_router`] builds the outbound client-identity policy from this hook, so
/// auction providers with `mtls = true` can present the `auction-providers` identity. The

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏ nitpick: Since the slot commit there is no auction-providers identity, only auction-providers-blue and auction-providers-green.

Suggested change
/// auction providers with `mtls = true` can present the `auction-providers` identity. The
/// auction providers with `mtls = true` can present the active slot's identity. The

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Present a client certificate on auction provider OpenRTB requests (mTLS)

2 participants