Honor configured proxies for realtime WebSocket connections (#47101)

## Why

Realtime WebSockets connected directly, bypassing the configured proxy policy for Voice's WebRTC sideband.

## What changed

Pass the configured `HttpClientFactory` into `RealtimeWebsocketClient` and connect through the shared `WebSocketConnector`. Add support for supplying an existing Rustls configuration to preserve custom CA handling and Windows platform trust.

## Testing

Add an integration test that enables `respect_system_proxy`, starts a WebRTC conversation, and verifies that the sideband establishes its session through an HTTP `CONNECT` proxy and closes successfully.

GitOrigin-RevId: d974c9275d7fe29f388d56a9d5d8ce0c483eb8d0
This commit is contained in:
Celia Chen
2026-09-21 20:05:21 +00:00
committed by copyberry
parent 8e7f50cba9
commit 142360dac8
7 changed files with 324 additions and 65 deletions
+8 -5
View File
@@ -43,11 +43,13 @@ pub struct WebSocketConnector {
tcp_nodelay: TcpNodelay,
}
/// Selects whether WebSocket TLS follows Codex custom-CA policy or Tungstenite defaults.
#[derive(Clone, Copy, PartialEq, Eq)]
/// Selects the TLS configuration used for WebSocket connections.
#[derive(Clone)]
pub enum WebSocketTlsMode {
/// Build an explicit TLS configuration from native roots and configured Codex custom CAs.
ExplicitCodexTls,
/// Use an existing Rustls configuration.
Rustls(Arc<ClientConfig>),
/// Let Tungstenite build its default TLS configuration when the target requires TLS.
TungsteniteDefault,
}
@@ -66,10 +68,10 @@ impl WebSocketConnector {
Self::new_with_tls_mode(http_client_factory, WebSocketTlsMode::ExplicitCodexTls)
}
/// Creates a connector with explicit Codex TLS or the transport's existing TLS defaults.
/// Creates a connector with the selected WebSocket TLS configuration.
///
/// HTTPS proxy connections still build Codex TLS configuration when they establish their
/// proxy tunnel; default-mode target connections otherwise remain entirely with Tungstenite.
/// With [`WebSocketTlsMode::TungsteniteDefault`], HTTPS proxy connections still build Codex
/// TLS configuration when they establish their proxy tunnel.
pub fn new_with_tls_mode(
http_client_factory: &HttpClientFactory,
tls_mode: WebSocketTlsMode,
@@ -78,6 +80,7 @@ impl WebSocketConnector {
WebSocketTlsMode::ExplicitCodexTls => {
Some(build_rustls_client_config_with_custom_ca()?)
}
WebSocketTlsMode::Rustls(config) => Some(config),
WebSocketTlsMode::TungsteniteDefault => None,
};
Ok(Self {