Skip to content

Commit 5b6dffc

Browse files
authored
fix(crypto): use ring for non-fips builds (#1816)
## What does this PR do? Switches the default (non-FIPS) crypto backend for rustls from `aws-lc-rs` to `ring` across all platforms, and changes reqwest's TLS feature from `rustls` to `rustls-no-provider` to prevent reqwest from forcing `aws-lc-rs` back into the dependency tree. ### Changes: - `libdd-common/Cargo.toml`: Removed `cfg(unix)`/`cfg(not(unix))` platform-specific rustls/hyper-rustls deps. Both now use `ring` unconditionally. Switched reqwest feature from `rustls` to `rustls-no-provider`. Pinned `rustls-native-certs` to `<0.8.3`. - `libdd-common/src/connector/mod.rs`: Simplified `ensure_crypto_provider_initialized()` to always install ring's provider, removing platform `#[cfg]` branches. - `libdd-profiling/Cargo.toml`: Same — removed platform split for rustls, unified on `ring`. Switched reqwest to `rustls-no-provider`. - `libdd-profiling/src/exporter/tls.rs`: Simplified `default_crypto_provider()` to always return ring's provider. - `libdd-http-client/Cargo.toml`: Switched `https` feature from `reqwest?/rustls` to `reqwest?/rustls-no-provider`. Added `rustls` with `ring` as dev-dependency for tests. - Test files: Added explicit `ensure_crypto_provider()` calls in `libdd-common/tests/reqwest_builder_test.rs` and all `libdd-http-client` test files, since `rustls-no-provider` does not auto-install a crypto provider. FIPS builds are unchanged — `hyper-rustls/fips` continues to activate `aws-lc-rs` as the FIPS-certified backend. ## Motivation Reduce binary size by eliminating `aws-lc-sys` (a large C crypto library) from non-FIPS builds. **Measured binary size reduction (macOS arm64, release profile):** | Artifact | Before (aws-lc-rs) | After (ring) | Savings | |---|---|---|---| | `libdatadog_profiling_ffi.dylib` | 9.0 MB | 7.8 MB | **1.2 MB (13%)** | | `libdatadog_profiling_ffi.a` | 154 MB | 145 MB | **9 MB (6%)** | The `.a` percentage is smaller because it contains all object files before link-time dead-code elimination. The `.dylib` reflects actual linked output where the crypto portion is a larger share of the total. Additionally, reqwest 0.13's `rustls` feature implicitly enables `__rustls-aws-lc-rs`, which forces `aws-lc-rs` into the tree regardless of what the consumer configures on rustls directly. This made it impossible to use ring-only builds without switching to `rustls-no-provider`. As a side effect, this also drops the `quinn`/QUIC HTTP/3 stack (`quinn`, `quinn-proto`, `quinn-udp`, `lru-slab`, `web-time`) from the dependency tree, which was being pulled in by reqwest's `rustls` feature but never used. This is the first step in a cross-repo effort to standardize on `ring` for non-FIPS and `aws-lc-rs` for FIPS-only across libdatadog and its downstream consumers. ## Additional Notes - `rustls-platform-verifier` in `libdd-profiling` is intentionally kept — it's there for the cert-caching performance fix (PR #1619), not for crypto backend selection. - `rustls-native-certs` is pinned to `>=0.8.1, <0.8.3` — version 0.8.3+ pulls in `openssl-probe@0.2` which probes multiple certificate directories and parses individual cert files instead of loading a single bundle, adding unnecessary I/O overhead in latency-sensitive environments. - The previous `cfg(unix)`/`cfg(not(unix))` split existed because `aws-lc-rs` had build issues on Windows. Since we're now using `ring` everywhere, the platform split is no longer necessary. - FIPS provider initialization remains the caller's responsibility — `ensure_crypto_provider_initialized()` is a no-op when the `fips` feature is enabled, and the caller must install the FIPS-compliant provider (e.g., `aws-lc-rs` FIPS) before any TLS connections. This is existing behavior, unchanged by this PR. ## How to test the change? - Verify `aws-lc-rs` is absent from the default dependency tree: ``` cargo tree --workspace -i aws-lc-rs # Expected: "error: package ID specification `aws-lc-rs` did not match any packages" ``` - Verify `ring` is the sole crypto backend: ``` cargo tree --workspace -i ring # Expected: ring present, used by rustls -> hyper-rustls -> libdd-common / libdd-profiling ``` - Verify FIPS builds still pull in `aws-lc-rs`: ``` cargo tree -p libdd-common --features fips -i aws-lc-rs # Expected: aws-lc-rs present via hyper-rustls/fips ``` - Verify full workspace compiles: ``` cargo check --workspace cargo check -p libdd-common --features fips ``` - Verify `rustls-native-certs` stays below 0.8.3: ``` cargo tree -p rustls-native-certs # Expected: v0.8.1 or v0.8.2 ``` Co-authored-by: jordan.gonzalez <jordan.gonzalez@datadoghq.com>
1 parent 2022fe0 commit 5b6dffc

18 files changed

Lines changed: 144 additions & 207 deletions

Cargo.lock

Lines changed: 16 additions & 131 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE-3rdparty.csv

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ hermit-abi,https://github.com/hermit-os/hermit-rs,MIT OR Apache-2.0,Stefan Lanke
175175
hex,https://github.com/KokaKiwi/rust-hex,MIT OR Apache-2.0,KokaKiwi <kokakiwi@kokakiwi.net>
176176
hickory-proto,https://github.com/hickory-dns/hickory-dns,MIT OR Apache-2.0,The contributors to Hickory DNS
177177
hickory-resolver,https://github.com/hickory-dns/hickory-dns,MIT OR Apache-2.0,The contributors to Hickory DNS
178-
home,https://github.com/rust-lang/cargo,MIT OR Apache-2.0,Brian Anderson <andersrb@gmail.com>
179178
http,https://github.com/hyperium/http,MIT OR Apache-2.0,"Alex Crichton <alex@alexcrichton.com>, Carl Lerche <me@carllerche.com>, Sean McArthur <sean@seanmonstar.com>"
180179
http-body,https://github.com/hyperium/http-body,MIT,"Carl Lerche <me@carllerche.com>, Lucio Franco <luciofranco14@gmail.com>, Sean McArthur <sean@seanmonstar.com>"
181180
http-body-util,https://github.com/hyperium/http-body,MIT,"Carl Lerche <me@carllerche.com>, Lucio Franco <luciofranco14@gmail.com>, Sean McArthur <sean@seanmonstar.com>"
@@ -220,7 +219,6 @@ js-sys,https://github.com/rustwasm/wasm-bindgen/tree/master/crates/js-sys,MIT OR
220219
kernel32-sys,https://github.com/retep998/winapi-rs,MIT,Peter Atashian <retep998@gmail.com>
221220
kv-log-macro,https://github.com/yoshuawuyts/kv-log-macro,MIT OR Apache-2.0,Yoshua Wuyts <yoshuawuyts@gmail.com>
222221
lazy_static,https://github.com/rust-lang-nursery/lazy-static.rs,MIT OR Apache-2.0,Marvin Löbel <loebel.marvin@gmail.com>
223-
lazycell,https://github.com/indiv0/lazycell,MIT OR Apache-2.0,"Alex Crichton <alex@alexcrichton.com>, Nikita Pekin <contact@nikitapek.in>"
224222
libc,https://github.com/rust-lang/libc,MIT OR Apache-2.0,The Rust Project Developers
225223
libloading,https://github.com/nagisa/rust_libloading,ISC,Simonas Kazlauskas <libloading@kazlauskas.me>
226224
libredox,https://gitlab.redox-os.org/redox-os/libredox,MIT,4lDO2 <4lDO2@protonmail.com>
@@ -230,7 +228,6 @@ linux-raw-sys,https://github.com/sunfishcode/linux-raw-sys,Apache-2.0 WITH LLVM-
230228
litemap,https://github.com/unicode-org/icu4x,Unicode-3.0,The ICU4X Project Developers
231229
lock_api,https://github.com/Amanieu/parking_lot,MIT OR Apache-2.0,Amanieu d'Antras <amanieu@gmail.com>
232230
log,https://github.com/rust-lang/log,MIT OR Apache-2.0,The Rust Project Developers
233-
lru-slab,https://github.com/Ralith/lru-slab,MIT OR Apache-2.0 OR Zlib,Benjamin Saunders <ben.e.saunders@gmail.com>
234231
manual_future,https://github.com/dmarcuse/manual_future,MIT,Dominic Marcuse <dominic@marcuse.us>
235232
matchers,https://github.com/hawkw/matchers,MIT,Eliza Weisman <eliza@buoyant.io>
236233
matchit,https://github.com/ibraheemdev/matchit,MIT AND BSD-3-Clause,Ibraheem Ahmed <ibraheem@ibraheem.ca>
@@ -323,9 +320,6 @@ pyo3-macros,https://github.com/pyo3/pyo3,MIT OR Apache-2.0,PyO3 Project and Cont
323320
pyo3-macros-backend,https://github.com/pyo3/pyo3,MIT OR Apache-2.0,PyO3 Project and Contributors <https://github.com/PyO3>
324321
quick-error,http://github.com/tailhook/quick-error,MIT OR Apache-2.0,"Paul Colomiets <paul@colomiets.name>, Colin Kiegel <kiegel@gmx.de>"
325322
quick-xml,https://github.com/tafia/quick-xml,MIT,The quick-xml Authors
326-
quinn,https://github.com/quinn-rs/quinn,MIT OR Apache-2.0,The quinn Authors
327-
quinn-proto,https://github.com/quinn-rs/quinn,MIT OR Apache-2.0,The quinn-proto Authors
328-
quinn-udp,https://github.com/quinn-rs/quinn,MIT OR Apache-2.0,The quinn-udp Authors
329323
quote,https://github.com/dtolnay/quote,MIT OR Apache-2.0,David Tolnay <dtolnay@gmail.com>
330324
r-efi,https://github.com/r-efi/r-efi,MIT OR Apache-2.0 OR LGPL-2.1-or-later,The r-efi Authors
331325
rand,https://github.com/rust-random/rand,MIT OR Apache-2.0,"The Rand Project Developers, The Rust Project Developers"
@@ -499,10 +493,8 @@ wasm-bindgen-macro,https://github.com/rustwasm/wasm-bindgen/tree/master/crates/m
499493
wasm-bindgen-macro-support,https://github.com/rustwasm/wasm-bindgen/tree/master/crates/macro-support,MIT OR Apache-2.0,The wasm-bindgen Developers
500494
wasm-bindgen-shared,https://github.com/rustwasm/wasm-bindgen/tree/master/crates/shared,MIT OR Apache-2.0,The wasm-bindgen Developers
501495
web-sys,https://github.com/rustwasm/wasm-bindgen/tree/master/crates/web-sys,MIT OR Apache-2.0,The wasm-bindgen Developers
502-
web-time,https://github.com/daxpedda/web-time,MIT OR Apache-2.0,The web-time Authors
503496
webpki-root-certs,https://github.com/rustls/webpki-roots,CDLA-Permissive-2.0,The webpki-root-certs Authors
504497
webpki-roots,https://github.com/rustls/webpki-roots,CDLA-Permissive-2.0,The webpki-roots Authors
505-
which,https://github.com/harryfei/which-rs,MIT,Harry Fei <tiziyuanfang@gmail.com>
506498
widestring,https://github.com/VoidStarKat/widestring-rs,MIT OR Apache-2.0,The widestring Authors
507499
winapi,https://github.com/retep998/winapi-rs,MIT,Peter Atashian <retep998@gmail.com>
508500
winapi,https://github.com/retep998/winapi-rs,MIT OR Apache-2.0,Peter Atashian <retep998@gmail.com>

0 commit comments

Comments
 (0)