GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tls: add tlsSocket.socket, to access the raw stream beneath TLS by pimterry · Pull Request #66598 · nodejs/node

Conversation

@pimterry

@pimterry pimterry commented Oct 8, 2026

Copy link
Copy Markdown
Member

If you created a TLS socket on top of an existing socket or duplex stream (new tls.TLSSocket(socket), tls.connect({ socket }), tlsServer.emit('connection', socket)) it's not possible to get the underlying socket back from the TLS socket through any public APIs.

Currently the only route to do this is the private _parent and _handle._parentWrap references, both of which are used in the ecosystem (including by my code) to workaround this issue. It would be nice if that wasn't necessary.

This PR adds a .socket property to TLS sockets, matching httpReq.socket and http2Session.socket. In reality in all 3 cases this might not actually be an actual socket - all 3 can run over any duplex - but the consistency is nice (it matches the option naming too) and it's clear enough imo.

There is notably one common case where this is still null: TLS client connections, made directly like tls.connect{ host, port }) (not using an existing socket). In this case there's no underlying net.Socket or stream object created, so there's nothing to expose. I think that's OK: the TLSSocket itself here is the raw socket, so there's no parent to reach and null is correct. It's noted in the docs here.

End result: when layering protocols on top of each other (e.g. H2 over TLS over H1 CONNECT), with this change you can just loop up the .socket references and you'll always (I think) eventually reach the real socket instance.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pimterry
tls: add tlsSocket.socket, to access the raw stream beneath TLS
20f2a00
Signed-off-by: Tim Perry <[email protected]>
@nodejs-github-bot

nodejs-github-bot commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/net
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@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 Oct 8, 2026
@codecov

codecov Bot commented Oct 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.44%. Comparing base (6d5e309) to head (20f2a00).
⚠️ Report is 147 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66598      +/-   ##
==========================================
- Coverage   90.44%   90.44%   -0.01%     
==========================================
  Files         791      791              
  Lines      276562   276565       +3     
  Branches    53126    53119       -7     
==========================================
- Hits       250130   250127       -3     
+ Misses      16846    16844       -2     
- Partials     9586     9594       +8     
Files with missing lines Coverage Δ
lib/internal/tls/wrap.js 95.62% <100.00%> (+<0.01%) ⬆️

... and 28 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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lpinca
lpinca approved these changes Oct 12, 2026
View reviewed changes
@lpinca lpinca 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 Oct 12, 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 Oct 12, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78346/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pimterry pimterry added the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Oct 13, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Oct 13, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78358/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pimterry pimterry added the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Oct 13, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Oct 13, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78361/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@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 Oct 15, 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 Oct 15, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78406/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pimterry pimterry added the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Oct 16, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Oct 16, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78434/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pimterry pimterry added the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 19, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 135b70e into nodejs:main Oct 19, 2026
95 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Landed in 135b70e

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 19, 2026
@aduh95 aduh95 mentioned this pull request Oct 27, 2026
2026-10-28, Version 27.0.0-alpha.0.0.0 (Alpha) #67062
Merged
aduh95 pushed a commit that referenced this pull request Nov 12, 2026
@pimterry @aduh95
tls: add tlsSocket.socket, to access the raw stream beneath TLS
ad94073
Signed-off-by: Tim Perry <[email protected]>
PR-URL: #66598
Reviewed-By: Luigi Pinca <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 20, 2026
2026-11-30, Version 26.14.0 'Lithium' (LTS) #67664
Open
@pimterry
pimterry deleted the tls-parent-socket branch November 26, 2026 16:09
gabylb pushed a commit to gabylb/node that referenced this pull request Nov 27, 2026
@pimterry @gabylb
tls: add tlsSocket.socket, to access the raw stream beneath TLS
ccc203d
Signed-off-by: Tim Perry <[email protected]>
PR-URL: nodejs#66598
Reviewed-By: Luigi Pinca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lpinca lpinca lpinca approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

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

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@pimterry @nodejs-github-bot @lpinca
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.