Skip to content

fix(tls): omit SNI for absent and null servernames - #171

Merged
steipete merged 1 commit into
mainfrom
claude/fix-tls-null-servername
Oct 14, 2026
Merged

steipete merged 1 commit into
mainfrom
claude/fix-tls-null-servername

Conversation

@steipete

@steipete steipete commented Oct 14, 2026 •

Copy link
Copy Markdown

What does this PR do?

Fixes tls.connect({ host: "127.0.0.1", servername: null }) sending 127.0.0.1 as SNI. A null name reached the native connection-host fallback. The Node TLS adapter now supplies an empty native name for absent/null/empty servernames and leaves certificate verification bound to the explicit name or connection host. Established Node sockets report false when no SNI was sent.

Direct tls.connect() does not infer SNI from a DNS host either. HTTPS agents already select it themselves; HTTP/2 now derives its name from the authority at its own layer. Existing option-normalization tests explicitly request the SNI name they assert.

Adapts the SNI layering fix from oven-sh/bun#33476 and the no-SNI socket property correction from oven-sh/bun#39088. Thanks @robobun! Neither proposal was merged; both were closed during stale-PR cleanup. Related #37013 covers embedded NUL validation and #42766 covers SQL IP names, separate contracts.

Node 24.21.0 sends an explicitly requested IP servername with DEP0123. This change preserves Bun's existing explicit-IP rejection; it fixes unintended SNI from absent names.

How did you verify your code works?

The built-ins-only fixture runs unchanged under Node 24.21.0. Its 34 cases cover direct IP/DNS TLS, socket upgrades, secure contexts, HTTPS agents, and HTTP/2. Each checks server-observed SNI, client servername, verification hostname, and authorization.

On a native Linux x64 release build:

  • Unpatched fork: the new matrix reports 11 pass / 23 fail (177 ms).
  • Patched fork: the complete hostname-verification file reports 45 pass / 0 fail (198 ms), including all 34 matrix cases and 11 existing certificate-verification tests.
  • Surrounding TLS, HTTP/2, and HTTPS coverage: the 42-file selection initially passed 1,126 tests. After installing test dependencies, using Node 24.21.0 with the existing version selector, and supplying the full standard internal-test environment, the two affected ordinary files passed 200 tests and the six internal-test files passed 120 tests. Existing platform/build-gated skips and todos remain unchanged. No remaining executed-test failures.
  • extensions/openai/image-generation-provider.tls.test.ts on the same downstream source: unpatched fork 1 pass / 2 fail (cross-origin and redirect scoping); patched fork 3/3 pass; Node 24.21.0 3/3 pass. Each run used isolated state.
  • Formatting, targeted lint, and independent Codex + Claude P2 reviews against openclaw/main pass.

The internal-test environment enables bun:internal-for-testing; it does not alter the SNI fix or test assertions. The implementation touches only portable JavaScript adapters, with no platform-specific TLS changes.

Commands for the focused regression and downstream consumer:

node test/js/node/tls/node-tls-servername-fixture.mjs
bun run build:release test test/js/node/tls/node-tls-connect-hostname-verification.test.ts
OPENCLAW_VITEST_RUNTIME=bun node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-provider-openai.config.ts extensions/openai/image-generation-provider.tls.test.ts

Fork CI passed on Linux x64 and macOS arm64: native build-and-test run. All 65 Linux and 66 macOS selected files passed, including the regression file, plus both direct net checks. Formatting and JavaScript lint passed. The unrelated issue-finder bot failed before analysis because its workflow lacks an Anthropic credential.

Keep raw tls.connect SNI explicit, preserve higher-level HTTPS and HTTP/2
name selection, and report false for established sockets without SNI.

Adapts oven-sh#33476 and oven-sh#39088 by @robobun.
Node 24.21.0 matrix and downstream TLS identity scoping pass.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T17:22:11.359746Z 6fba7b7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete
steipete merged commit 1d2fe9e into main Oct 14, 2026
6 of 7 checks passed
@steipete
steipete deleted the claude/fix-tls-null-servername branch October 14, 2026 17:38
steipete added a commit to steipete/bun that referenced this pull request Oct 28, 2026
Pass an explicit empty native name when tls.connect has no servername,
while preserving pending setServername state and hostname verification.
Keep HTTP/2 authority defaults in the HTTP/2 adapter and report false on
established client sockets without SNI.

Supersedes stale oven-sh#33476 by robobun; thanks @robobun.
Ports openclaw#171. Related to the unwanted SNI in oven-sh#20727.
steipete added a commit to steipete/bun that referenced this pull request Nov 14, 2026
Pass an explicit empty native name when tls.connect has no servername,
while preserving pending setServername state and hostname verification.
Keep HTTP/2 authority defaults in the HTTP/2 adapter and report false on
established client sockets without SNI.

Supersedes stale oven-sh#33476 by robobun; thanks @robobun.
Ports openclaw#171. Related to the unwanted SNI in oven-sh#20727.
steipete added a commit to steipete/bun that referenced this pull request Nov 21, 2026
Pass an explicit empty native name when tls.connect has no servername,
while preserving pending setServername state and hostname verification.
Keep HTTP/2 authority defaults in the HTTP/2 adapter and report false on
established client sockets without SNI.

Supersedes stale oven-sh#33476 by robobun; thanks @robobun.
Ports openclaw#171. Related to the unwanted SNI in oven-sh#20727.
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.

1 participant