Skip to content

grpc-js: Don't set an IP address as the TLS servername - #3129

Open
orgads wants to merge 1 commit into
grpc:masterfrom
orgads:no-ip-servername
Open

orgads wants to merge 1 commit into
grpc:masterfrom
orgads:no-ip-servername

Conversation

@orgads

@orgads orgads commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #3127. Node.js 25 made DEP0123 End-of-Life, so tls.connect throws ERR_INVALID_ARG_VALUE when servername is an IP address. Secure channels to an IP target never connect, and the caller only sees 14 UNAVAILABLE.

 getConnectionOptions
   if grpc.ssl_target_name_override
     servername = override
-  else
+  else if !net.isIP(remoteHost)
     servername = remoteHost

Node's own https agent skips SNI for IP addresses in the same way. Certificate verification is unchanged: checkServerIdentity still gets the IP and checks it against the certificate's IP SANs.

Evidence

New test Should connect to an IP address target in test-channel-credentials.ts connects to 127.0.0.1:<port> with no name override.

  • Before, on Node.js v26.12.1: 14 UNAVAILABLE: No connection established. Last error: TypeError [ERR_INVALID_ARG_VALUE]: ... Setting the TLS ServerName to an IP address is not permitted.. Received '127.0.0.1'
  • After: passes, and all 15 tests in the file pass.

On Node.js 24 and older the test passes either way, because an IP servername only triggers a warning there.

To run the TLS tests on Node.js 26 I had to lower OpenSSL to security level 1 (--openssl-config with CipherString = DEFAULT@SECLEVEL=1). The fixture keys are 1024-bit, and Node 26's default rejects them with ee key too small, with or without this change.

Merge Danger

Door: two-way.

Blast Radius: TLS channels whose target is an IP address with no grpc.ssl_target_name_override. They no longer send SNI, which Node.js already left out for IP addresses before it started throwing.

🤖 Generated with Claude Code

Node.js 25 made DEP0123 End-of-Life, so tls.connect throws when
servername is an IP address, and secure channels to an IP target
never connect. Skip SNI for IP targets, as Node's https agent does.

Fixes grpc#3127

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

grpc-js: secure channel to an IP address fails on Node 25+ (servername set to IP literal)

1 participant