chore: put crypto provider logic in a shared crate (#11294)

Ensures a process-wide rustls crypto provider is installed.

Both the `codex-network-proxy` and `codex-api` crates need this.
This commit is contained in:
Michael Bolin
2026-02-10 01:04:31 -08:00
committed by GitHub
parent 9fded117ac
commit 8e240a13be
10 changed files with 62 additions and 12 deletions
@@ -0,0 +1,6 @@
load("//:defs.bzl", "codex_rust_crate")
codex_rust_crate(
name = "rustls-provider",
crate_name = "codex_utils_rustls_provider",
)
+11
View File
@@ -0,0 +1,11 @@
[package]
name = "codex-utils-rustls-provider"
version.workspace = true
edition.workspace = true
license.workspace = true
[lints]
workspace = true
[dependencies]
rustls = { workspace = true }
+12
View File
@@ -0,0 +1,12 @@
use std::sync::Once;
/// Ensures a process-wide rustls crypto provider is installed.
///
/// rustls cannot auto-select a provider when both `ring` and `aws-lc-rs`
/// features are enabled in the dependency graph.
pub fn ensure_rustls_crypto_provider() {
static RUSTLS_PROVIDER_INIT: Once = Once::new();
RUSTLS_PROVIDER_INIT.call_once(|| {
let _ = rustls::crypto::ring::default_provider().install_default();
});
}