Skip to content

tls: ignore a terminal dot when matching SNI contexts - #67639

Open
ShogunPanda wants to merge 1 commit into
nodejs:mainfrom
ShogunPanda:tls-sni-terminal-dot
Open

ShogunPanda wants to merge 1 commit into
nodejs:mainfrom
ShogunPanda:tls-sni-terminal-dot

Conversation

@ShogunPanda

Copy link
Copy Markdown
Contributor

server.addContext() and the SNI callback compared the names as written, so a client sending host.example. (with a terminal dot) did not match a context registered for host.example, and vice versa, although both names refer to the same host. Remove one terminal dot from both sides before matching so the same context is selected.

Testing: added test/parallel/test-tls-sni-trailing-dot.js (TLSv1.2 and TLSv1.3, exact and wildcard names, with and without the terminal dot). The parallel/test-tls-* and parallel/test-https-* suites and eslint pass.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. tls Issues and PRs related to the tls subsystem. labels Nov 20, 2026
The names given to `server.addContext()` and the server name sent by
the client were compared as written, so `host.example.` did not match
a context added for `host.example`, although both name the same host.
Remove one terminal dot from both before matching, so that the same
context is selected.

Assisted-By: OpenAI GPT-5.6 Sol <openai/gpt-5.6-sol>
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.72%. Comparing base (0482448) to head (2139721).
⚠️ Report is 100 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67639      +/-   ##
==========================================
- Coverage   90.72%   90.72%   -0.01%     
==========================================
  Files         801      801              
  Lines      280889   280918      +29     
  Branches    54240    54256      +16     
==========================================
+ Hits       254829   254852      +23     
- Misses      16245    16249       +4     
- Partials     9815     9817       +2     
Files with missing lines Coverage Δ
lib/internal/tls/wrap.js 95.82% <100.00%> (+0.02%) ⬆️

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jasnell
jasnell requested a review from pimterry November 22, 2026 20:32

@jasnell jasnell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but a decision about whether this neesd to be semver-major or not needs to be made.

@pimterry pimterry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I don't think this is semver major, seems like a reasonable bug fix to me, and we've certainly never documented or expected the old behaviour. And this is a patch for an invalid edge case anyway, the SNI spec forbids this entirely, so normal clients should never send it:

The hostname is represented as a byte string using ASCII encoding without a trailing dot.

Happy to bake for LTS if we'd like, but I'm not too worried.

@pimterry pimterry added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 23, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 23, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. tls Issues and PRs related to the tls subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants