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

オープン 初心者向け
#3,127 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@orgads がすでに取り組んでいます。

2026年11月7日 から。

  • #3129 @orgads による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
75/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
grpc, node.js, typescript

調査の方向性

channel-credentials.ts の getConnectionOptions から始め、次に SecureConnectorImpl.connect が tls.connect のエラーをどのように処理するか確認してください。issue の再現例では、IP を宛先にした場合は失敗し、ホスト名を宛先にした場合は成功します。Node 26 でその再現例を使って動作を確認してください。IP リテラルを servername として渡さずに IP 宛先へ接続でき、ホスト名宛先への接続も引き続き成功すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Problem description

Credentials from createSsl() cannot connect to a target given by IP address on Node 25 and later.

getConnectionOptions in channel-credentials.ts sets servername = remoteHost unconditionally (since #1466). Node 25 made DEP0123 End-of-Life (nodejs/node#58533), so tls.connect now throws instead of warning when servername is an IP literal:

ERR_INVALID_ARG_VALUE: The property 'options.servername' Setting the TLS ServerName to an IP address is not permitted.. Received '127.0.0.1'

The throw happens inside the connect promise in SecureConnectorImpl.connect, so the caller only ever sees 14 UNAVAILABLE: No connection established. Hostname targets work. Node 26 is the current LTS, so this now hits default installs.

Reproduction steps

Any TLS gRPC server listening on 127.0.0.1:PORT, then:

const grpc = require('@grpc/grpc-js');
const client = new grpc.Client('127.0.0.1:PORT',
  grpc.credentials.createSsl(null, null, null, { rejectUnauthorized: false }));
client.waitForReady(Date.now() + 2000, err => console.log(err ? err.message : 'connected'));

Node 24: connected
Node 26: Failed to connect before the deadline

Wrapping tls.connect to log its options shows servername: '127.0.0.1' on every attempt, and the synchronous ERR_INVALID_ARG_VALUE throw.

Environment
  • Linux 7.0, amd64
  • Node v26.13.0 (works on v24.17.0)
  • fnm
  • @grpc/grpc-js 1.14.7, same code on master
Additional context

Node's own https agent already skips SNI for IP literals. Same one-line change here:

if (!net.isIP(remoteHost)) {
  connectionOptions.servername = remoteHost;
}
主要言語
TypeScript
スター
4.8k
フォーク
720
平均マージ
2日 11時間
マージ済み PR(30日)
7

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

grpc/grpc-node のほかの issue

grpc/grpc-node の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。