Skip to content

Commit ef664bf

Browse files
committed
fix: replace per-build keychain enumeration with shared platform verification
1 parent 3cc5ebd commit ef664bf

6 files changed

Lines changed: 246 additions & 36 deletions

File tree

Cargo.lock

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

crates/aft/Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ base64 = "0.22"
100100
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "gif", "webp"] }
101101
memchr = "2"
102102
rayon = "1"
103-
# Keep the Mozilla bundle and platform roots active together so private/corporate
104-
# CAs are trusted without losing the static webpki fallback.
105-
reqwest = { version = "0.12", default-features = false, features = ["blocking", "json", "rustls-tls", "rustls-tls-native-roots"] }
103+
# Use rustls-platform-verifier for per-connection OS trust checks instead of
104+
# enumerating native roots while every reqwest client is built.
105+
reqwest = { version = "0.12", default-features = false, features = ["blocking", "json", "rustls-tls"] }
106+
rustls = { version = "0.23", default-features = false, features = ["ring"] }
107+
rustls-platform-verifier = "0.6"
106108
tree-sitter-scss = { package = "cortexkit-tree-sitter-scss", version = "1.0.1" }
107109
# Local embedding backend (all-MiniLM-L6-v2) driven directly through ort, so we
108110
# control intra-op thread count (fastembed hardcoded all-cores). hf-hub fetches
@@ -135,4 +137,3 @@ landlock = "=0.4.5"
135137
tempfile = "3"
136138
filetime = "0.2"
137139
rcgen = "0.13"
138-
rustls = { version = "0.23", default-features = false, features = ["ring"] }

crates/aft/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ pub mod parser;
9292
pub mod patch;
9393
pub mod path_identity;
9494
pub mod pattern_compile;
95+
mod platform_tls;
9596
pub mod protocol;
9697
pub mod pty_render;
9798
pub mod query_shape;

crates/aft/src/platform_tls.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use std::sync::OnceLock;
2+
3+
use rustls::ClientConfig;
4+
use rustls_platform_verifier::ConfigVerifierExt;
5+
6+
static PLATFORM_VERIFIER_CONFIG: OnceLock<Result<ClientConfig, String>> = OnceLock::new();
7+
8+
/// Return the process-wide platform-verifier TLS configuration.
9+
///
10+
/// The configuration is initialized only when the first HTTPS-capable client is
11+
/// built. Cloning it for reqwest is cheap because the verifier and its shared
12+
/// state are reference counted; importantly, native trust decisions remain
13+
/// connection-time work instead of per-client root-store enumeration.
14+
pub(crate) fn client_config() -> Result<ClientConfig, String> {
15+
PLATFORM_VERIFIER_CONFIG
16+
.get_or_init(|| {
17+
// Reqwest enables rustls' ring provider, but does not install a
18+
// process default provider for callers that supply their own config.
19+
let _ = rustls::crypto::ring::default_provider().install_default();
20+
ClientConfig::with_platform_verifier()
21+
.map_err(|error| format!("failed to create platform TLS verifier: {error}"))
22+
})
23+
.clone()
24+
}

0 commit comments

Comments
 (0)