Fix regional proxy TLS chain validation with local relay - #1479
Draft
sammacbeth wants to merge 3 commits into
Draft
Fix regional proxy TLS chain validation with local relay#1479sammacbeth wants to merge 3 commits into
sammacbeth wants to merge 3 commits into
Conversation
dew.socks.duckduckgo.com (region de) serves only its leaf TLS cert without the Let's Encrypt E7 intermediate, breaking direct Chromium proxy connections (ERR_PROXY_CERTIFICATE_INVALID). Add launchRegionalProxyBrowserViaRelay/startRegionalProxyRelay, which fetch the missing intermediate from the leaf cert's AIA URL and verify against it plus Node's trusted roots, so the chain is completed instead of skipping verification. Verified end-to-end against the privacy-test-pages autoconsent test rule.
- Fold the chain-repair relay into launchRegionalProxyBrowser itself instead of a separate opt-in launchRegionalProxyBrowserViaRelay, so testUrl/testRegions get a working connection for any region without callers having to pre-diagnose which host is broken. - Replace the always-run discard-probe (2 handshakes per host, forever) with try-strict-first-then-repair-on-failure, cached per host: hosts with a complete chain pay one handshake, hosts needing repair pay two only once. - Extract readConnectResponse() to stop duplicating the CONNECT status-line parsing between connectRaw and the relay's outbound CONNECT, and flatten the callback pyramid into async/await. Verified against the privacy-test-pages rule: de (needs repair) still passes end-to-end, and a second run reuses the cached CA.
Contributor
Release label check failedPlease update this PR's release labels before merging. Current labels: Problems:
Required labels:
See docs/release-notes.md for examples. |
The missing-intermediate-cert symptom this works around was diagnosed in a Claude Cloud (CCR sandbox) session. Note in both the skill doc and the source that other environments may never hit it, and can disregard the gotcha if they don't.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes an issue where launching a browser through certain regional proxies (e.g.,
dew.socks.duckduckgo.comfor regionde) fails withERR_PROXY_CERTIFICATE_INVALIDbecause those hosts don't send their complete TLS certificate chain.Changes
New local relay: Introduced
startRegionalProxyRelay()that runs a local HTTP CONNECT proxy on127.0.0.1. Chromium now points itsproxysetting at this relay instead of directly at the region host.Transparent chain repair: The relay uses
connectRegionalProxyTls()to establish TLS connections to the region host. When a connection fails due to an incomplete certificate chain (UNABLE_TO_VERIFY_LEAF_SIGNATURE), it automatically:Secure credential handling: The TLS connection to the region host always uses
rejectUnauthorized: true, ensuring proxy credentials are never sent over an unverified connection.Gateway support: Added
connectRaw()to support tunneling through$HTTPS_PROXYwhen set (needed in sandboxed environments like CCR).Helper functions added
derToPem()— converts DER-encoded certificates to PEM formatfetchAiaIntermediate()— fetches intermediate certificates from AIA URLsreadConnectResponse()— parses HTTP CONNECT tunnel responsesconnectRaw()— opens raw sockets with optional gateway tunnelingtlsConnect()— promisified TLS connectiondiscoverMissingIntermediate()— probes a host's certificate to find missing intermediatesconnectRegionalProxyTls()— establishes verified TLS to region hosts with automatic chain repairUpdated documentation
Updated
SKILL.mdto document the new relay behavior and the transparent certificate chain repair mechanism.Steps to test this PR
Launch a browser through a region with an incomplete certificate chain (e.g.,
de):Verify the browser launches successfully without certificate validation errors.
Verify the relay caches intermediates by launching multiple browsers for the same region and confirming subsequent launches complete faster.
Test in a sandboxed environment with
$HTTPS_PROXYset to ensure gateway tunneling works.https://claude.ai/code/session_01AicQ6vbdBFqqmZnDALPfHP