Fix TLS negotiation for plain SOCKS proxies - #118
Open
gilnatab (gilnatab) wants to merge 2 commits into
Open
Conversation
gilnatab (gilnatab)
marked this pull request as ready for review
September 5, 2026 09:44
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.
With Undici 7.29.0, patched
fetchcan't connect through plain SOCKS5 proxies.createProxyAgentalways passesproxyTls, which tells Undici to use TLS for the proxy connection. It then sends a TLS handshake where the proxy expects a SOCKS5 handshake.This PR passes
proxyTlsonly for HTTPS proxies. It parses the URL first, so bothhttps://andHTTPS://keep the proxy's CA settings.requestTlsstill handles TLS to the target server.This also breaks SOCKS5 over TLS connections that worked before. Local tests of patched
fetchwith@vscode/proxy-agent0.44.0 and Undici 7.29.0 gave these results for both HTTP and HTTPS targets:If anyone relies on SOCKS5 over TLS through patched
fetch, their requests would stop working after this change. We don't know whether anyone currently uses this setup.Before merging, please decide whether we need to add a library option and a VS Code setting for SOCKS5 over TLS now, or whether they can come later. This PR doesn't add them. Users would need both to turn TLS back on through VS Code settings.
The tests cover plain SOCKS5 handshakes and lowercase/uppercase HTTPS proxy URLs. The code compiles, and unit tests pass on Node 22.22.2.
Related issue: openai/codex#35924. Local tests also reproduced this connection problem.