Skip to content

fix(codex): honor env proxies for WebSockets - #83

Merged
raine merged 2 commits into
raine:mainfrom
ItsAlbertZhang:fix/codex-websocket-env-proxy-pr
Jul 29, 2026
Merged

fix(codex): honor env proxies for WebSockets#83
raine merged 2 commits into
raine:mainfrom
ItsAlbertZhang:fix/codex-websocket-env-proxy-pr

Conversation

@ItsAlbertZhang

Copy link
Copy Markdown
Contributor

Summary

Codex HTTP requests already honor standard proxy environment variables, but WebSocket connections were opened directly. This meant the default WSS transport could require OS-level TUN routing even when an HTTP or SOCKS proxy was configured.

This change adds explicit environment-proxy support for Codex WebSocket setup:

  • uses HTTP_PROXY for ws:// and HTTPS_PROXY for wss://
  • supports ALL_PROXY fallback and NO_PROXY bypass
  • supports HTTP, HTTPS, SOCKS4/4A, and SOCKS5/5H proxy URLs
  • supports proxy credentials where the underlying protocol permits them
  • preserves CGI proxy-variable protection
  • fails closed instead of silently retrying a selected proxy route directly

It also:

  • preserves both platform-native and public WebPKI trust roots
  • handles fragmented CONNECT responses and any successful 2xx status
  • preserves tunnel bytes read together with the CONNECT response
  • keeps proxy authentication out of destination requests, logs, traffic captures, and errors
  • strengthens WebSocket handshake validation
  • documents non-TUN proxy configuration and restart behavior

Testing

  • cargo fmt --all -- --check
  • cargo check --locked
  • focused Codex WebSocket proxy integration tests
  • full cargo test --locked suite with loopback NO_PROXY isolation
  • strict Clippy with 12 pre-existing baseline lints explicitly allowed

The full test suite passed, including 9 Codex WebSocket proxy integration tests and the existing pooling, continuation, authentication, retry, and smoke-cutover coverage.

Not run: Astro documentation build, because the documentation dependencies were not installed.

🤖 Generated with Claude Code

ItsAlbertZhang and others added 2 commits July 29, 2026 11:14
Route Codex WebSocket upgrades through standard proxy environment semantics, including HTTP(S), SOCKS, NO_PROXY, and CGI protection. Preserve native and WebPKI trust roots, robustly handle CONNECT responses, and prevent undeclared direct fallback. Harden handshake validation and credential redaction with local proxy coverage and portable documentation.
Loading platform certificates for every reqwest client made Codex provider
construction exceed the existing streaming startup deadline on macOS. The
native-roots reqwest feature also changed trust policy and initialization cost
for unrelated providers.

Keep reqwest's bundled public roots as the crate-wide default. Build one shared
Codex WebSocket TLS configuration from platform and public roots, then use that
configuration for both reqwest WebSocket upgrades and explicit CONNECT
tunnels. Report native certificate loading and parsing failures by count.

This preserves enterprise proxy trust without repeated platform store scans or
cross-provider TLS changes. There are no breaking configuration changes.
@raine
raine force-pushed the fix/codex-websocket-env-proxy-pr branch from 7563e3e to 30267d3 Compare July 29, 2026 09:17
@raine
raine merged commit 30d5916 into raine:main Jul 29, 2026
@raine

raine commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants