Repository navigation
Add mutual TLS client certificate authentication on HTTPS listeners - #1300
Conversation
FlorentinDUBOIS
left a comment
There was a problem hiding this comment.
Cross-review (5 lenses + Codex cross-check)
Reviewed 1518d93e across /review, /review-code, /security-review, /guidelines, /simplify, plus an independent OpenAI Codex pass. 9 raw findings → 4 after dedupe → 4/4 survived adversarial refutation, 0 dropped.
What checked out clean
The security core of this feature is correct and fails closed — verified against the vendored rustls 0.23.42 source, not from memory:
client_cert_verifierrejects unknown/garbageclient_authenum values viaClientAuthMode::try_fromrather than silently degrading toNONE.- A non-
NONEmode with an empty CA bundle is rejected; a CA/CRL PEM entry parsing to zero objects is rejected rather than silently dropped (the before/after.len()check is sound —RootCertStore::adddoes not dedupe). - CRL expiration is unconditionally enforced (
enforce_revocation_expiration()), andWebPkiClientVerifier's defaultUnknownStatusPolicy::Denyis left intact. allow_unauthenticated()(OPTIONAL) matches its rustls contract: a presented certificate is still fully chain-validated — no silent bypass.try_new/create_rustls_contextreturnResult, so a listener that fails to build its verifier is never activated — no fallback to an unauthenticated listener.UpdateHttpsListenerConfigcarries no mTLS fields, so a running listener's policy cannot be downgraded by a runtime patch; the ALPN-change rebuild path reuses the existing config.- Protobuf/serde back-compat is sound: field numbers 48–50 don't collide,
Option<i32>defaults toNonewithout#[serde(default)], and therepeatedfields correctly do carry it.
Codex additionally scripted a live TLS handshake exercising OPTIONAL/REQUIRED with and without a client certificate and confirmed correct accept/reject behavior; its verdict was "no actionable defect attributable to this commit". cargo check --workspace --all-features, cargo clippy -p sozu-lib -p sozu-command-lib -- -D warnings, and the 12 new unit tests all pass. No correctness or security defect was found.
What's left (4 inline comments)
| Severity | Finding |
|---|---|
| 🟡 medium | doc/configure.md not updated for the three new TOML keys (CONTRIBUTING.md "docs are code") |
| 🔵 low | HttpsListenerConfig's hand-written Debug impl omits the new mTLS fields |
| 🔵 low | New helper orphans to_http's doc comment |
| 🔵 low | No end-to-end handshake test, despite the existing tcp_sni_tests.rs mTLS pattern |
Nothing here is a defect in the shipped logic — the blocking item is the documentation rule. Details inline.
Grounded at head 1518d93eba16072d6da2e53b3f6decc198abde97.
1518d93 to
2c3c092
Compare
|
Thanks for the thorough pass, especially for grounding the rustls behaviour against the vendored source rather than from memory. All four findings are addressed.
🟡 medium — undocumented TOML keysAdded a The matrix distinguishes the two rejection stages, which the description in this PR conflated: reading the CA/CRL files and rejecting mTLS keys on a non-HTTPS listener happen at config-load in the master, while PEM parsing and verifier construction happen worker-side. Also updated, as you flagged: One thing I did not carry over from your comment: the 🔵 low —
|
| Test | Asserts |
|---|---|
test_mtls_required_rejects_client_without_cert |
no response and requests_received == 0 |
test_mtls_required_accepts_trusted_client_cert |
HTTP/1.1 200 + backend reached |
test_mtls_optional_accepts_client_without_cert |
HTTP/1.1 200 + backend reached |
The reject test asserts an untouched backend, not just an absent response: absence alone would also pass if Sōzu admitted the session and answered a 4xx, which is not what required means.
They reuse the e2e/assets/tcp_sni/ CA and client identity (mtls-client-cert.pem chains to ca-cert.pem and carries the TLS Web Client Authentication EKU). Since HttpsListenerConfig carries inlined PEM rather than paths, the tests mutate the generated config in place, same approach as the existing disable_http11 test.
Mutation-checked against exactly the bypass you described: flipping allow_unauthenticated() from the OPTIONAL arm to the REQUIRED one makes required_rejects and optional_accepts both fail, while every unit test in lib/src/https.rs still passes. That pair is what pins the mode boundary.
Verification
cargo clippy --all-targets -- -D warnings and cargo +nightly fmt --check clean; tls_tests 12/12; the 8 verifier unit tests and the sozu-command-lib suite green. CI is green on 2c3c092f except Docker build and push to Docker Hub, which fails identically on 1518d93e (fork credentials, unrelated to this change).
The master-side validation limitation from the PR description is unchanged and still looks like a separate issue to me.
|
Thx, I will take another look tomorrow |
FlorentinDUBOIS
left a comment
There was a problem hiding this comment.
Automated cross-review (review / review-code / Rust guidelines / security-review + Codex, adversarially verified). Three findings are inline and were submitted as one batched review.
|
Hi @Shine-neko — this branch is now 60 commits behind Two jobs are red on that August run, and they have different causes — only one of them is yours to fix:
One other reason a rerun is worth it: Thanks for the contribution, and sorry it has been sitting. |
9071bce to
c5e8130
Compare
|
Rebased on |
51584c8 to
6947899
Compare
Fixes #1800 ## Summary A backend that accepts no connection (blackholed: SYN dropped, accept queue full) hit `connect_timeout` and the request was answered `504`. The timeout path marked the connection `Disconnecting`, so the dead-backend branch of `Mux::ready_inner`, the only place a connect failure is counted, never saw it. The backend's retry policy was never armed and the load balancer kept picking it. - **Connect timeout counts as a connect failure.** `Mux::timeout_inner` now flags a still-`Connecting` connection's readiness `ERROR`, the way the kernel flags a refused dial. `Server::timeout` then runs the `ready` pass that only it can trigger (new `ProxySession::needs_ready_pass`, default `false`). That pass reuses the existing dead-backend branch: it counts the failure (`failures`, `retry_policy`, `backend.connections.error`, `backend.down`), closes the connection, and re-links the request through `EndStreamAction::Reconnect`. The request sent no byte, so it is safe to resend. A response timeout on an established connection still answers `504`. - **A WRITABLE event no longer marks a connecting socket connected.** `SO_ERROR` (`take_error`) is read first, then `getpeername(2)`. An error is a connect failure. `ENOTCONN` means the WRITABLE was raised by Sōzu itself, not by the kernel, so the connection waits for the kernel's completion edge. This fixes a separate defect you can observe on its own: on `main`, a dial from an `http2 = true` cluster to a blackholed backend was marked connected and then hung until `back_timeout`. - **A synchronous `connect(2)` failure is retried** instead of being answered `503` at once. - **Each retry skips the backends that already failed for this request** (`Stream::tried_backends`), for every load-balancing policy. The exclusion narrows the candidate set (`BackendList::select_with_key_excluding`). If every selectable backend was already tried, selection falls back to the plain behaviour, fail-open included, so the request retries one of them instead of being refused. A sticky cookie that names a tried backend is not followed. - **The retry budget is configurable.** `max_connection_attempts` counts every attempt, the first included. It replaces the hard-coded `CONN_RETRIES = 3`, and **the default is now 5**. It can be set: - globally: TOML and `ServerConfig` field 29; - per cluster: `Cluster` field 23, TOML, `sozu cluster add --max-connection-attempts`, and `sozu cluster connection-attempts set|unset` (query, then re-send with the field changed, like `cluster h2`). A cluster table column shows the value; - at runtime on every worker: `sozu connection-attempts set` (`Request.set_max_connection_attempts`, field 62). Like `connection-limit set`, this is not saved. Allowed range is `1..=255`. It is validated at config load, on `AddCluster` (main and worker), and on the runtime set. A cluster value wins over the global one, for both HTTP and TCP clusters. - **Failover is bounded by `front_timeout`.** The frontend's nominal timeout is set only on a request's first link, not on every re-link. The deadline armed then therefore bounds the whole failover, so a request can no longer run for `max_connection_attempts × connect_timeout`. When the deadline expires during failover, the request gets the frontend timeout's existing answer: `504`, with access-log message `client_timeout_during_response`. `doc/configure.md` recommends keeping `connect_timeout` well below `front_timeout / max_connection_attempts`, and explains how back-off grows. - **Socket error logged.** The socket error read by `take_error()` is logged at `debug!`, the same level as the synchronous-refusal path. **Status change for alerting:** when every attempted backend is unreachable (connect timeout or refused), the answer is now `503`. A connect timeout used to answer `504`. Requests that arrive during a back-off window can also fail fast with `503`. Operators alerting on `504` rates should watch `503`, `backend.connections.error` and `backend.connect.retries_exhausted` instead. With the default budget at 5, an idempotent request on a stale keep-alive connection can be replayed to up to 4 backends (`n - 1`), against 2 before. **Coordination:** `Request` field 62 is also used by the open PR #1300. That PR already needs renumbering, so this one keeps 62. **Library API break:** `sozu_lib::server::CONN_RETRIES` is removed, and new fields are added to `Cluster`, `ServerConfig`, `RequestType`, `FileConfig`, `FileClusterConfig`, `HttpClusterConfig`, `TcpClusterConfig`, `Stream` and `SessionManager`. Upgrade the main process, the workers and the CLI together before setting a per-cluster budget: an older CLI that patches clusters by read-modify-write drops the field. Docs: `doc/configure.md` (new "Backend connection failover" section, global key, metrics, shard and replay budget text), `doc/configure_cli.md`, `doc/health_checks.md`, `doc/lifetime_of_a_session.md`, `doc/rate-limit-design.md`, `lib/src/protocol/mux/LIFECYCLE.md` §7.3, `bin/config.toml`, and `CHANGELOG.md`. ## Existing tests touched Two existing tests now call `mark_connected(h1)` in their fixtures: `a_backend_timeout_leaves_no_linked_stream_behind_on_the_close_path` and `a_completed_backend_response_timeout_unlinks_through_end_stream_alone`. Both describe a backend that has already sent response bytes, but their fixture left it `Connecting`. With this change, a `Connecting` connection is treated as a connect timeout. No assertion changed, and neither test encodes the old `504`; they cover the response-timeout arms. An alternative would be to narrow the timeout branch to `Connecting && no linked stream has back.consumed`. I kept the fixture fix instead, because that extra condition cannot be reached in production. ## Tests New: `e2e/src/tests/backend_failover_tests.rs`, plus `connect_outcome_tests`, `exclusion_tests`, `a_connect_timeout_flags_the_dial_dead_instead_of_answering_504`, the `max_connection_attempts` config tests, and the state validation test. What each test proves: - The connect-timeout e2e tests use 3 healthy and 3 blackholed backends with `connect_timeout = 1`. The blackhole is a backlog-0 listener with a full accept queue; `test_blackholed_listener_times_out` checks that it really times out. Every request must answer 200, and the cluster-level `backend.connections.error` must be greater than 0. That counter shows the timeouts are now counted against the backend, which arms its retry policy. It does not measure a drop in how often dead backends are picked. - The refused-backend e2e tests use a refused/healthy alternation that drives the first request onto three refused backends in a row. The budget raise is what fixes them. The tried set itself is covered by `exclusion_tests`. ## CI fix: leaked mock backend threads CI on `9bd8bfa6` and `379b4a4e` failed `tests::h2_tests::test_h2_rapid_reset_triggers_goaway` in every cell ("received 0 frames"). The cause was in this PR's test module, not in production code. **Cause:** `Backends` in `e2e/src/tests/backend_failover_tests.rs` dropped its `AsyncBackend` handles without stopping them. That backend's thread (`e2e/src/mock/async_backend.rs`, the spawn loop) only exits on a stop message, so every dropped handle left a thread spinning for the rest of the test process. That was about two dozen threads, all started before `h2_tests` in name order. On a small CI runner they starved the rapid-reset worker: CI logged its 999 resets over 12 s, in batches of about 17 every 110 ms. Main's CI run took 0.16 s for the same resets, with identical per-stream timings. **Fix:** `impl Drop for Backends` now stops those backends. The rapid-reset test is unchanged. **Evidence:** I ran `taskset -c 0 cargo test -p sozu-e2e --locked -- backend_failover tests::h2_tests::test_h2_rapid_reset_triggers_goaway --test-threads=4 --nocapture` before and after the fix. - Before: about 24 threads were busy during the rapid-reset test (`ps -L`), and the 999 resets took 1.57 s instead of 0.1 s. - After: no busy leftover threads, and the 999 resets took 0.32 s. - The full e2e suite dropped from 3098 s to 1963 s. ## CI fix: worker events read as answers At `dff0285e`, `test_connect_timeout_fails_over_h2` failed in the crypto-openssl cell even though every request got its 200. The test's metrics query read a worker event (`content_type: Some("event")`) in place of its answer. The failover tests make backends fail on purpose, and a backend whose retry policy gives up on it is reported `BACKEND_DOWN` on the same command channel. Reads in these tests now skip events (`read_answer`). That event's arrival depends on randomized back-off, so I did not reproduce the race locally. After the fix, both connect-timeout tests passed 20 runs out of 20 under `taskset -c 0`, and 20 out of 20 on 2 CPUs loaded with 6 busy processes. Validation at head `6c7dd668`, after merging origin/main `320e86d6` (#1805; conflicts in `command/src/config.rs` and `doc/health_checks.md` resolved keeping both features): Verified: `cargo +nightly fmt --all -- --check` -> exit 0 Verified: `cargo +1.93.1 clippy --all-features --all-targets --locked -- -D warnings` -> exit 0 Verified: `cargo test -p sozu-lib --lib --all-features` -> `test result: ok. 1586 passed; 0 failed` Verified: `cargo test -p sozu-command-lib -p sozu --all-features --locked` -> exit 0, all `test result: ok` (227 command-lib unit tests) Verified: `cargo test -p sozu-e2e --features opentelemetry,splice,simd -- --test-threads=4` -> `test result: ok. 621 passed; 0 failed` Verified: `RUSTDOCFLAGS="-D warnings" cargo +1.93.1 doc --no-deps --locked -p sozu-lib -p sozu-command-lib -p sozu` -> exit 0 (An earlier run at `f8d4c18e` had one timing failure under load: `test_h1_chunked_encoding_edge_cases`. That test passed 3 times out of 3 in isolation, and the full `h1_security_tests` module passed with `--test-threads=4`.) Verified: `python3 .github/scripts/check_doc_citations.py --root . --base origin/main` -> exit 0 Red without the fix: - New e2e tests on `main` (`dc25d2ff`): - `test_connect_timeout_fails_over_h1`/`_h2`: `[200, 504, 200, 504, …]` (12×200, 12×504) and `backend.connections.error: 0`. - `test_refused_backends_never_exhaust_attempts_h1`/`_h2`: first request `503`. - `test_h2_backend_connect_failure_fails_over_h1`/`_h2`: `[200, 0, 200, 200, 0, …]`, where `0` is no answer within 10 s. - `test_failover_is_bounded_by_front_timeout_h1`/`_h2` (6 blackholed backends, budget 20, `connect_timeout` 1 s, `front_timeout` 3 s): - in a scratch copy of this branch with the per-attempt re-arm restored: no answer within 10 s on both frontends; - with the fix: `[504]` after about 3.09 s on both. - `try_connect_timeout_fails_over` now asserts `backend.connections.error >= 3`, one failure per blackholed backend. Round robin hits each of the six backends in the first six requests, so this is deterministic. - Budget and unit tests, in scratch copies of this branch with one part of the fix reverted at a time: - default set back to 3: `test_default_connection_attempt_budget_is_five` fails (`503`), and so does the config default test; - cluster override ignored: `…overrides_global` fails (`503`), and so do the runtime cluster update and the default test's per-cluster `four`; - runtime setter disabled: `…changes_at_runtime` fails (`200` where `503` is expected); - exclusion, fallback or sticky filter removed: the matching `exclusion_tests` fail; - `ENOTCONN` treated as connected: `a_dial_nobody_answers_is_pending` and the H2-backend e2e tests fail; - `Connecting` early return removed: `a_connect_timeout_flags_the_dial_dead_instead_of_answering_504` fails; - validation removed: the config and state range tests fail. Signed-off-by: Florentin Dubois <[email protected]>
|
Heads-up on protobuf field numbers: |
|
None of the tests at The logic reads correct to me. Since
@FlorentinDUBOIS, want this in #1300 or separately? Happy to send the throwaway CA plus revoked and expired CRLs as a commit against the branch. |
|
I think it will be great to have the full lifecycle with revocation, I do not really mind about having a large diff, as long as there are tests for lifecycle of each features and also we do not reduce quality of others. Also, could you update the documentation as well? |
6947899 to
aeafd91
Compare
|
@FlorentinDUBOIS rebased on @Santoshkumarpuppala thanks for the detailed pointers, no need to send the fixtures. The branch now has a throwaway CA with current, revoking, expired and foreign-issuer CRLs ( |
|
I am launching a code review :D |
FlorentinDUBOIS
left a comment
There was a problem hiding this comment.
Thanks for the update; the protobuf number collision is fixed (Request = 63).
This review combines two passes on head 58a4cfc:
- a code review, which traced each issue in the code;
- a guidelines check, which built and tested the PR head and its merge with current main.
The build is clean:
- clippy
-D warningson the crypto-ring, aws-lc-rs, openssl and fips cells; - rustdoc, fmt and doc citations;
- tests: lib 1650, bin 316, command 270, e2e TLS 31 (all 7
test_mtls_*); - the merge with main is conflict-free and builds and tests green.
Mutating enforce_revocation_expiration, reject_crls_sharing_an_issuer, allow_unauthenticated and into_canonical each turns a test red.
Inline comments, most important first:
- CRL/CA refresh is impossible through a reload, and CRL expiry is enforced.
- CA/CRL paths without
client_authare silently ignored. - Partitioned CRLs are refused, and an expired CRL is accepted at load.
- Rollback and state-size effects of embedding PEMs.
- Client identity isn't forwarded to backends.
The rest are doc and nit items.
Two items have no line in the diff:
- Commit
3e3b8cb9f(feat(https): add mutual TLS...) has noSigned-off-by, and none of the 9 commits is GPG-signed. The repo convention is signed-off and GPG-signed commits (-s -S). bin/config.tomlhas no example forclient_auth,client_ca_certificatesandclient_ca_crls.
3eb523b to
41ce5f8
Compare
FlorentinDUBOIS
left a comment
There was a problem hiding this comment.
Re-review at 41ce5f8. Thanks, the previous round is addressed.
- Resolved:
- Reload now refreshes the CA bundle and CRLs (
client_auth_refreshplus theclient_auth_policypatch onRequest64). - CA or CRL files without
client_authare rejected. - Partitioned CRLs are accepted and an already-expired CRL is refused.
- The doc comment is back on
client_cert_verifier. - The always-true
debug_asserts are removed. - Main-process validation is documented.
- The rollback procedure and the
load_statebuffer size are handled. - The display.rs citation path is fixed.
- The CHANGELOG blank line and proto numbers are added.
bin/config.tomlhas the new keys.- The client identity limitation is documented.
- Reload now refreshes the CA bundle and CRLs (
- Partly addressed:
to_owned, with one production.to_string()left; the validation matrix still places one check in the worker. Both are inline. - Commits: all 15 now carry
Signed-off-by. None is GPG-signed.
Two CI jobs are red at this head, each with a one-line cause, explained inline:
msrv-full: a misplaced doc block incommand/src/state.rstriggers rustdoc's private intra-doc link error.Doc citations: two proto field names in the CHANGELOG are read as test names.
Both fixes pass locally.
Also inline: a stale "not patchable" paragraph in the listener mutability section, a few doc nits, and a question on the CRL expiry check running on every worker-side build.
Checked locally at 41ce5f8 with --no-default-features --features crypto-ring:
- sozu-lib (1626 tests) and sozu-command-lib (265 tests) pass.
- The three new bin tests pass: reload CRL refresh, 200 kB state record, and fan-out verb.
- The 7
test_mtls_*e2e tests pass. - The branch is 7 commits behind main, and
git merge-treeagainst current main is clean. Request63/64,HttpsListenerConfig51-53 andUpdateHttpsListenerConfig45 are still free on main.
FlorentinDUBOIS
left a comment
There was a problem hiding this comment.
Re-review at c07b797. Thanks, all 8 points from the previous round are addressed:
- The
update_https_listenerdoc block sits on itsfnagain, andmsrv-fullis green. - The CHANGELOG cites the variant names and names
ConfigError::ClientAuthModeMissing.Doc citationsis green. - In
doc/configure.md, the stale "not patchable" paragraph is rewritten, the duplicate bullets are merged, and the trust-set row says main process. - The proto comment is fixed.
- The CRL expiry refusal now runs only in the main process, on authored requests. Workers and state replays still build the listener, so a later reload can patch it. The new bin test and the updated e2e cover this.
to_ownedis used in display.rs.
CI: 36/36 checks green at this head. Both new commits carry Signed-off-by, but neither is GPG-signed, like the previous 15. git merge-tree --write-tree origin/main is clean, and the branch is 8 commits behind main.
Unchanged behaviour without mTLS keys. I found no change to the TLS path or the wire for a deployment that sets no client_auth / client_ca_* key. What I checked:
- Wire: I ran one probe binary from the same TOML at main (95094cd) and at this head. The protobuf bytes match for every config message (
AddHttpsListenerincluded), for theInitialStatea new worker or upgrade receives, and for an ALPNUpdateHttpsListenerpatch. Optional/repeated fields left unset are not encoded, and the audit SHA hashes those same bytes. Non-mTLS requests keep their verbs, both fromRequestType::add_https_listenerand afterinto_canonicalinscatter_on. So any mix of old and new main, worker or CLI decodes them as before. - Config:
ListenerBuilderisdeny_unknown_fields, so no existing file can contain the new keys. The two new errors and the warning fire only when one of those keys is present. - Handshake:
client_cert_verifierreturnsNonebefore any allocation, so the builder takeswith_no_client_auth()at the same place. ALPN, tickets, resolver and session settings are untouched. The only extra cost is oneArcclone per listener build, and nothing per handshake. - Reload: in the head probe,
client_auth_refreshreturnsNonefor the non-mTLS listener, andConfigState::diffof the same config is empty. Soload_static_configemits nothing new.validate_client_crls_currentandvalidate_client_auth_policyreturnOkearly on empty input. - Metrics and access logs: the diff adds no metric macro and does not touch
lib/src/protocol. Theinfo!lines that print{:?}of listeners print fd lists (Listeners), notHttpsListenerConfig. - Tests at head (
--no-default-features --features crypto-ring,-j4): sozu-lib 1626 and sozu-command-lib 265 pass, as do the sozu bin tests (166 per target). e2e:test_mtls/tls_/httpsgives 60 passed, 9 of them mTLS and 51 non-mTLS TLS/HTTPS.upgrade/listener_updategives 31 passed.
Three observable differences remain, all minor:
sozu listener listnow shows three extra rows for every HTTPS listener (inline).- Boot and
sozu state loadallocate a larger parse buffer (inline). save_stateJSON gains"client_auth":null,"client_ca_certificates":[],"client_ca_crls":[]on each HTTPS listener record ("client_auth_policy":nullon a patch). Every new proto field does the same. The merge-base binary parses all 7 head-written records, so a rollback still reads the state file. No action needed.
92c0484 to
16a4cae
Compare
…S listeners Signed-off-by: Mlanawo MBECHEZI <[email protected]>
…t auth Signed-off-by: Mlanawo MBECHEZI <[email protected]>
… in listener display Signed-off-by: Mlanawo MBECHEZI <[email protected]>
…orkers cannot decode Signed-off-by: Mlanawo MBECHEZI <[email protected]>
…CRL fixtures Signed-off-by: Mlanawo MBECHEZI <[email protected]>
…hake Signed-off-by: Mlanawo MBECHEZI <[email protected]>
Signed-off-by: Mlanawo MBECHEZI <[email protected]>
…lient auth Signed-off-by: Mlanawo MBECHEZI <[email protected]>
Signed-off-by: Mlanawo MBECHEZI <[email protected]>
…e on reload Signed-off-by: Mlanawo MBECHEZI <[email protected]>
Signed-off-by: Mlanawo MBECHEZI <[email protected]>
…es at listener build Signed-off-by: Mlanawo MBECHEZI <[email protected]>
…h no client_auth mode Signed-off-by: Mlanawo MBECHEZI <[email protected]>
…ring literals Signed-off-by: Mlanawo MBECHEZI <[email protected]>
…ion, add an mTLS config example Signed-off-by: Mlanawo MBECHEZI <[email protected]>
…states it Signed-off-by: Mlanawo MBECHEZI <[email protected]>
…eview Signed-off-by: Mlanawo MBECHEZI <[email protected]>
…client auth key is set Signed-off-by: Mlanawo MBECHEZI <[email protected]>
…TLS section Signed-off-by: Mlanawo MBECHEZI <[email protected]>
16a4cae to
a661a58
Compare
FlorentinDUBOIS
left a comment
There was a problem hiding this comment.
All review threads addressed, CI green at a661a58. Without client_auth configured the listener keeps the historical with_no_client_auth path and the historical AddHttpsListener/UpdateHttpsListener verbs. Thanks!
Closes #1299.
What
Adds mutual TLS (client certificate authentication) to HTTPS listeners. Until now
lib/src/https.rshardcoded.with_no_client_auth(), so verifying a client certificate was impossible.Configuration
A per-listener
client_authmode drives the rustlsWebPkiClientVerifier:none: current behavior, no CertificateRequest is sentoptional: requests a certificate, admits clients presenting none; a presented certificate must still validaterequired: aborts the handshake unless the client presents a certificate chaining to a trusted CACA and CRL files are read at config-load.
sozu reloadrefreshes them on a running listener in place: when the policy it reads differs from the running one, it sends anUpdateHttpsListenerConfigwhoseclient_auth_policyreplaces mode, CAs and CRLs together, and the workers rebuild the verifier for new handshakes.Wire compatibility
HttpsListenerConfigfields 51-53,UpdateHttpsListenerConfigfield 45 (ClientAuthPolicy), newClientAuthModeenum whose zero value isCLIENT_AUTH_NONE. Absent fields decode to today's behavior; the repeated fields carry#[serde(default)], so older state files load.AddHttpsListenerWithClientAuth(Request63) and a policy patch asUpdateHttpsListenerWithClientAuth(Request64). A worker that predates this change cannot decode them, so it fails the request instead of building the listener without client auth or keeping its old CRLs. The main process rewrites every fan-out to these verbs (RequestType::into_canonical).Fail-closed behavior
Rejected rather than silently degraded, by the main process before commit (and again by each worker when it builds the listener):
client_authvalue, or a non-nonemode with no trusted CAclient_authkey (an explicitnoneis allowed, with a warning)nextUpdateIssuingDistributionPoints are acceptedRevocation is checked over the whole chain, unknown status is denied, and CRL expiry is enforced at handshake (
enforce_revocation_expiration).Limitations (documented in
doc/configure.md)optionalprovides no access control by itself andrequiredadmits any trusted certificate to every frontend of the listener.AddHttpsListenerWithClientAuthrecord; the doc gives the procedure.Tests
lib/src/https.rs: verifier construction, revocation verdicts against real CRL fixtures (lib/assets/mtls/, regenerated bygenerate.sh) asserting the exact rustls error, CRL set checks, in-place policy patch.command/src/: config-load inlining and rejections, verb selection, old-worker decoding of both new verbs, state patch and reload refresh.bin/src/command/: fan-out verb, reload refresh throughload_static_config,load_statewith a record larger than 200 kB.e2e/src/tests/tls_tests.rs:test_mtls_*handshakes for each mode, each CRL case, and a policy patch sequence on a running listener.cargo clippy --all-targets --locked -- -D warnings,cargo +nightly fmt --all -- --checkand the doc citation check pass.