You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cosmos: add configurable TLS backend, enforced on reqwest (#4649)
## Problem
The driver does not expose direct access to its HTTP transport (and
won't, in a supported fashion). As a result, customers have no supported
way to assert a specific TLS backend on the officially-supported
`reqwest` transport.
## Change
Introduces a supported, forward-looking mechanism to select and enforce
the TLS backend.
- **`TlsBackend` enum** — `#[non_exhaustive]`, one variant
`TlsBackend::Rustls` (the `#[default]`). Added to
`azure_data_cosmos_driver` and re-exported from `azure_data_cosmos`.
- **`ConnectionPoolOptions::tls_backend`** — new option with
`ConnectionPoolOptionsBuilder::with_tls_backend` and a `tls_backend()`
getter, defaulting to `Rustls`. Builder-only (intentionally **not**
environment-configurable).
- **Enforced on reqwest** — `DefaultHttpClientFactory::build` selects
the backend and calls `reqwest::ClientBuilder::tls_backend_rustls()`.
The call is cfg-gated on the `rustls` feature because that reqwest
method only exists when reqwest's rustls backend is compiled in; under a
different TLS feature the reqwest default applies.
Because there is a single variant and it is the default, **no customer
configuration is required today**. The value is forward-looking: it lets
us add new backends in a supported way, and (once #4616 lands) hand the
selected backend to a user-provided `HttpClientFactory`.
## Files
- `options/policies.rs` — new `TlsBackend` enum.
- `options/mod.rs` (driver) and `options/mod.rs` (SDK) — export /
re-export `TlsBackend`.
- `options/connection_pool.rs` — `tls_backend` field, builder field,
`with_tls_backend`, getter, default wiring; extended option tests.
- `driver/transport/http_client_factory.rs` — enforce the backend on the
reqwest builder; factory build test.
- `CHANGELOG.md` (driver `0.6.0`, SDK `0.37.0`) — Features Added
entries.
## Testing & coverage
**Unit (added):**
- `connection_pool_options_builder_defaults` — default `tls_backend()`
is `Rustls`.
- `connection_pool_options_builder_custom_values` — `with_tls_backend()`
round-trips through the builder.
- `default_factory_builds_client_with_default_tls_backend`
(`reqwest`-gated) — builds a real `reqwest::Client` with the default
backend, exercising `tls_backend_rustls()` and asserting `build()`
succeeds.
**Suites / static checks (green):** 1878 driver lib unit tests; `cargo
clippy --all-features --all-targets`; `cargo doc`; `cargo fmt --check`;
cSpell. Compile verified for both the `rustls` and the `not(rustls)`
(`reqwest` + `native_tls`) feature paths — the main risk surface for the
cfg-gated call.
**Integration testing:** No dedicated integration test is added, by
design. `Rustls` is the only variant and the default, and the default
feature set already used reqwest-over-rustls — so behavior is unchanged
and the existing emulator/recorded integration suites already exercise
the rustls transport path end-to-end. A bespoke test could not assert
more, because reqwest exposes no API to introspect which TLS backend
negotiated a connection; the added factory test already proves the
client builds and runs with the enforced backend.
Fixes#4641.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: sdk/cosmos/azure_data_cosmos/CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@
4
4
5
5
### Features Added
6
6
7
+
- Added `TlsBackend` (re-exported) and a `tls_backend` option on `ConnectionPoolOptions` (`ConnectionPoolOptionsBuilder::with_tls_backend`), defaulting to `TlsBackend::Rustls`, available under the `rustls` feature, to pin the TLS backend used by the transport. This is additive and changes no behavior for the default (rustls) build; it only has an effect in builds that compile in multiple reqwest TLS backends, where reqwest would otherwise default to native-tls and the driver now pins rustls instead. ([#4649](https://github.com/Azure/azure-sdk-for-rust/pull/4649))
Copy file name to clipboardExpand all lines: sdk/cosmos/azure_data_cosmos_driver/CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@
4
4
5
5
### Features Added
6
6
7
+
- Added `TlsBackend` (currently `TlsBackend::Rustls`, the default) and a `tls_backend` option on `ConnectionPoolOptions` (`ConnectionPoolOptionsBuilder::with_tls_backend` / `ConnectionPoolOptions::tls_backend`), available under the `rustls` feature. The driver asserts the selected backend on the `reqwest` transport, giving a supported way to pin the TLS backend without direct transport access. This is additive and changes no behavior for the default (rustls-only) build, where reqwest already negotiates rustls; it only has an effect in builds that compile in multiple reqwest TLS backends (e.g. `rustls` plus `native_tls`, absent reqwest's `http3` feature), where reqwest would otherwise default to native-tls and the driver now pins rustls instead. ([#4649](https://github.com/Azure/azure-sdk-for-rust/pull/4649))
0 commit comments