Repository navigation
Conversation
Node.js 25 moved DEP0123 to end-of-life, so tls.connect() throws ERR_INVALID_ARG_VALUE when servername is an IP address. Socks5ProxyAgent uses the target host as servername when it upgrades the tunnel to TLS, so every request to an https://<ip>/ target through a SOCKS5 proxy fails. Node.js 24 only warned and sent the IP as SNI. Drop a servername that is an IP literal, and pass host: targetHost so the certificate is checked against the target and not against the SOCKS5 proxy socket's host. Signed-off-by: Wei-Lun Li <b84330808@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
This relates to...
#6144 (the SOCKS5 part; the ProxyAgent part is covered by #6148)
Rationale
Node.js 25 moved DEP0123 to end-of-life, so
tls.connect()throwsERR_INVALID_ARG_VALUEwhen theservernameis an IP address.Socks5ProxyAgentpasses the target host as the servername when it upgrades the tunnel to TLS, so every request to anhttps://<ip>/target through a SOCKS5 proxy fails there. On Node.js 24 it only warned, and sent the IP as SNI.Changes
In
lib/dispatcher/socks5-proxy-agent.js, the TLS upgrade now drops the servername when it is an IP literal (whether it came from the target host or from the request TLS options), and passeshost: targetHostso the certificate is checked against the target and not against the proxy socket's host. Passing nohostwould make Node verify against the proxy's host instead. IPv6 targets are unaffected because the address is already bracket/colon handled upstream andnet.isIPcovers both families.Two tests are added to
test/socks5-proxy-agent.js: an HTTPS target addressed by IPv4 completes the request and sends no SNI, and a hostname target still sends SNI as before.Features
N/A
Bug Fixes
Socks5ProxyAgentrequests tohttps://<ip>/targets throwingERR_INVALID_ARG_VALUEon Node.js 25+Breaking Changes and Deprecations
None
Status
I ran
test/socks5-proxy-agent.jsmyself on Linux with Node v24.22.1: with the old code the new no-SNI test fails (1 failure), with this change the file passes (22 pass, 1 skipped).