Skip to content

Fix regional proxy TLS chain validation with local relay - #1479

Draft
sammacbeth wants to merge 3 commits into
mainfrom
claude/proxy-test-skill-validation-napb0l
Draft

Fix regional proxy TLS chain validation with local relay#1479
sammacbeth wants to merge 3 commits into
mainfrom
claude/proxy-test-skill-validation-napb0l

Conversation

@sammacbeth

Copy link
Copy Markdown
Collaborator

Description

Fixes an issue where launching a browser through certain regional proxies (e.g., dew.socks.duckduckgo.com for region de) fails with ERR_PROXY_CERTIFICATE_INVALID because those hosts don't send their complete TLS certificate chain.

Changes

  • New local relay: Introduced startRegionalProxyRelay() that runs a local HTTP CONNECT proxy on 127.0.0.1. Chromium now points its proxy setting 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:

    1. Fetches the missing intermediate certificate via the host's AIA "CA Issuers" URL
    2. Retries the connection with the intermediate included
    3. Caches the intermediate for future connections to the same host
  • 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_PROXY when set (needed in sandboxed environments like CCR).

Helper functions added

  • derToPem() — converts DER-encoded certificates to PEM format
  • fetchAiaIntermediate() — fetches intermediate certificates from AIA URLs
  • readConnectResponse() — parses HTTP CONNECT tunnel responses
  • connectRaw() — opens raw sockets with optional gateway tunneling
  • tlsConnect() — promisified TLS connection
  • discoverMissingIntermediate() — probes a host's certificate to find missing intermediates
  • connectRegionalProxyTls() — establishes verified TLS to region hosts with automatic chain repair

Updated documentation

Updated SKILL.md to document the new relay behavior and the transparent certificate chain repair mechanism.

Steps to test this PR

  1. Launch a browser through a region with an incomplete certificate chain (e.g., de):

    const browser = await launchRegionalProxyBrowser('de');

    Verify the browser launches successfully without certificate validation errors.

  2. Verify the relay caches intermediates by launching multiple browsers for the same region and confirming subsequent launches complete faster.

  3. Test in a sandboxed environment with $HTTPS_PROXY set to ensure gateway tunneling works.

https://claude.ai/code/session_01AicQ6vbdBFqqmZnDALPfHP

claude added 2 commits August 5, 2026 16:44
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.
@github-actions github-actions Bot added the category: ai Changes to agent workflows and skills label Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Release label check failed

Please update this PR's release labels before merging.

Current labels: category: ai

Problems:

  • Add exactly one version label with the version: prefix.

Required labels:

  • One version label using the version: prefix, for example version: patch
  • One release-note category label using the category: prefix, for example category: rules

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: ai Changes to agent workflows and skills

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants