Skip to content

Commit a8831a7

Browse files
committed
login: harden custom CA handling and isolate env-based tests
Enterprise TLS inspection proxies use custom roots, so OAuth token exchanges fail when we only trust system CAs. This change switches PEM parsing to rustls-pki-types (multi-cert bundles included) and surfaces clearer, user- facing errors that explain how to fix invalid or empty CA files via CODEX_CA_CERTIFICATE/SSL_CERT_FILE. To avoid cross-test races with process-wide env vars, CA path selection now uses a small EnvSource abstraction in unit tests, and environment-dependent behavior is verified via an assert_cmd-driven login_ca_probe helper binary. This keeps normal tests isolated while still validating env precedence and error messaging. Also updates login dev-deps (assert_cmd/pretty_assertions), removes serial_test, and re-exports build_login_http_client for the probe helper.
1 parent 99b566d commit a8831a7

File tree

7 files changed

+282
-232
lines changed

7 files changed

+282
-232
lines changed

codex-rs/Cargo.lock

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

codex-rs/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ regex = "1.12.2"
177177
regex-lite = "0.1.7"
178178
reqwest = "0.12"
179179
rmcp = { version = "0.10.0", default-features = false }
180+
rustls-pki-types = "1.13.0"
180181
schemars = "0.8.22"
181182
seccompiler = "0.5.0"
182183
sentry = "0.34.0"

codex-rs/login/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ codex-core = { workspace = true }
1414
codex-app-server-protocol = { workspace = true }
1515
rand = { workspace = true }
1616
reqwest = { workspace = true, features = ["json", "blocking"] }
17+
rustls-pki-types = { workspace = true }
1718
serde = { workspace = true, features = ["derive"] }
1819
serde_json = { workspace = true }
1920
sha2 = { workspace = true }
@@ -32,7 +33,8 @@ webbrowser = { workspace = true }
3233

3334
[dev-dependencies]
3435
anyhow = { workspace = true }
36+
assert_cmd = { workspace = true }
3537
core_test_support = { workspace = true }
38+
pretty_assertions = { workspace = true }
3639
tempfile = { workspace = true }
3740
wiremock = { workspace = true }
38-
serial_test = { workspace = true }
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//! Helper binary for exercising custom CA environment handling in tests.
2+
//!
3+
//! The login flows honor `CODEX_CA_CERTIFICATE` and `SSL_CERT_FILE`, but those
4+
//! environment variables are process-global and unsafe to mutate in parallel
5+
//! test execution. This probe keeps the behavior under test while letting
6+
//! integration tests (`tests/ca_env.rs`) set env vars per-process, proving:
7+
//! - env precedence is respected,
8+
//! - multi-cert PEM bundles load,
9+
//! - error messages guide users when CA files are invalid.
10+
11+
use std::process;
12+
13+
fn main() {
14+
match codex_login::build_login_http_client() {
15+
Ok(_) => {
16+
println!("ok");
17+
}
18+
Err(error) => {
19+
eprintln!("{error}");
20+
process::exit(1);
21+
}
22+
}
23+
}

codex-rs/login/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub use device_code_auth::run_device_code_login;
66
pub use server::LoginServer;
77
pub use server::ServerOptions;
88
pub use server::ShutdownHandle;
9+
pub use server::build_login_http_client;
910
pub use server::run_login_server;
1011

1112
// Re-export commonly used auth types and helpers from codex-core for compatibility

0 commit comments

Comments
 (0)