A client can use HTTP CONNECT to request a tunnel to an HTTPS target. Ordinary tunneling relays TLS bytes, leaving the client and origin as TLS endpoints. SSL Bumping terminates and recreates TLS, changing that end-to-end trust relationship. Separate tunnel establishment, byte forwarding and resource queues.
1. The Mechanics of HTTP CONNECT: State Machine Transition
In HTTP/1.1, a successful 2xx response to CONNECT starts a bidirectional byte tunnel, not an IP-packet tunnel. A supporting proxy can use epoll for nonblocking connect(), but EPOLLOUT requires checking SO_ERROR before treating the connection as successful and returning, for example, 200 Connection Established. Buffering, half-closes and errors still need handling; FDs are not automatically chained. HTTP/2 and HTTP/3 CONNECT operate on streams rather than destroying the entire HTTP state machine.
Mermaid Diagram: Advanced Connection Flow
sequenceDiagram
participant Client
participant Proxy (Kernel/User)
participant Origin Server
Note over Client, Proxy (Kernel/User): 1. Proxy TCP Handshake & Queueing
Client->>Proxy (Kernel/User): TCP SYN
Proxy (Kernel/User)->>Client: TCP SYN-ACK
Note over Client, Proxy (Kernel/User): 2. HTTP CONNECT & DNS
Client->>Proxy (Kernel/User): CONNECT origin.example:443 HTTP/1.1
Proxy (Kernel/User)->>Proxy (Kernel/User): NSS getaddrinfo() / Async DNS
Proxy (Kernel/User)->>Origin Server: TCP SYN (Non-blocking)
Origin Server->>Proxy (Kernel/User): TCP SYN-ACK
Proxy (Kernel/User)->>Client: HTTP/1.1 200 Connection Established
Note over Client, Origin Server: 3. Zero-Copy TLS Tunneling (splice syscall)
Client->>Proxy (Kernel/User): TLS Client Hello (SNI)
Proxy (Kernel/User)->>Origin Server: splice(client_fd, origin_fd)
Origin Server->>Proxy (Kernel/User): TLS Server Hello, Cert
Proxy (Kernel/User)->>Client: splice(origin_fd, client_fd)
Note over Client, Origin Server: 4. Encrypted Application Data
Client->>Origin Server: Encrypted AES-GCM Frames
Origin Server->>Client: Encrypted AES-GCM Frames
2. Advanced Proxy Architecture: Zero-Copy and splice()
Relaying with read() and write() involves userspace buffers and syscalls. Cost depends on batching, caching and workload. A supporting proxy path can choose splice(); read/write alone does not establish CPU or memory-bus saturation.
At least one splice() endpoint must be a pipe, so socket-to-socket relay normally uses two calls through a pipe. This avoids moving data through userspace but can still involve kernel copying, scheduling and syscall costs. The diagram’s two-FD shorthand is not a complete function signature; getaddrinfo is not inherently an asynchronous syscall. Tens of gigabits with near-zero userspace CPU needs a specific benchmark that is not supplied here.
3. Mathematical Rigor: Queueing Theory and Little’s Law
Little’s Law relates \(\lambda\), \(W\) and \(L\) within a stable measurement boundary with matching average arrival/completion rates and finite averages. For outbound connection attempts, use the same attempt population for arrival rate and residence time, including failures/timeouts. The result is a mean population in that state, not peak concurrency.
\[ L = \lambda W \]
At fixed arrivals, increasing \(W\) increases modeled mean \(L\), potentially approaching FD limits (ulimit -n) or destination-tuple-related port capacity. An \(M/M/c\) model requires assumptions such as Poisson arrivals, exponential service and homogeneous servers. Its \(c\) is not simply the number of async event loops. Erlang C gives a waiting probability, not a finite-capacity rejection/blocking probability. Size from actual concurrency, timeout and resource limits.
4. Advanced Tooling: eBPF Traffic Interception and Metrics
CONNECT latency includes client-to-proxy travel, authorization, DNS, queues and upstream connection establishment. Version-specific kprobes may use tcp_v4_connect or tcp_rcv_state_process; XDP is a packet hook, not a probe attached to those functions.
#include <bcc/proto.h>
#include <net/sock.h>
// Trace tcp_connect to track proxy-to-origin latency
int kprobe__tcp_connect(struct pt_regs *ctx, struct sock *sk) {
u32 pid = bpf_get_current_pid_tgid();
u64 ts = bpf_ktime_get_ns();
// Store socket pointer and timestamp
bpf_map_update_elem(&connect_start, &sk, &ts, BPF_ANY);
return 0;
}
The retained fragment only stores a start timestamp; map definition, loading, completion events and histogram output are missing. Even a completed PID/socket-correlated measurement gives connection-establishment time, not established-connection RTT or full CONNECT latency. Kernel timestamps do not eliminate every scheduling or queueing influence.
5. Post-Mortem: SSL Bumping and Egress Policies
SSL Bumping creates separate client-to-proxy and proxy-to-origin TLS sessions in a managed trust environment. The proxy presents a replacement certificate trusted by the client and separately validates the upstream. Missing trust, pinning or validation failures can reject the connection; after CONNECT, X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN is one possible error rather than a guaranteed code.
Furthermore, secure egress architectures must enforce strictly whitelisted CONNECT ACLs. Unrestricted CONNECT methods are notoriously exploited by attackers to bounce traffic via the proxy to internal VPC endpoints (e.g., CONNECT 10.0.0.5:22), weaponizing the proxy as an internal network pivot.
6. CONNECT Troubleshooting Table
For a CONNECT tunnel failure, distinguish proxy authorization, tunnel establishment, TLS negotiation, and upstream reachability. The table below lists the evidence for each stage.
| Failure point | Evidence to collect | Likely cause | Validation step |
|---|---|---|---|
| Proxy rejects CONNECT | HTTP status, proxy auth header, ACL rule, and target host/port. | Missing credentials or egress policy denies the destination. | Replay a minimal CONNECT host:443 request with known credentials. |
| Tunnel opens but TLS fails | SNI, ALPN, certificate chain, and handshake alert. | The proxy is tunneling correctly but the TLS endpoint rejects the client. | Compare openssl s_client -proxy with direct connection output. |
| Long tail latency | Queue length, socket buffer state, splice/sendfile path, and upstream RTT. | Proxy event loop or upstream path is saturated. | Measure proxy accept-to-connect and connect-to-first-byte separately. |
| SSL bumping breaks apps | Installed root CA, pinning errors, CONNECT policy, and audit log. | The proxy changed the TLS trust boundary for a pinned or sensitive app. | Exclude pinned destinations or move inspection to an explicitly managed environment. |