Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resetAndDestroy can not be called on tlssocket? #49484

Open
LongTengDao opened this issue Dec 17, 2022 · 5 comments · May be fixed by #53160
Open

resetAndDestroy can not be called on tlssocket? #49484

LongTengDao opened this issue Dec 17, 2022 · 5 comments · May be fixed by #53160
Labels
confirmed-bug Issues with confirmed bugs.

Comments

@LongTengDao
Copy link
Contributor

LongTengDao commented Dec 17, 2022

Details

Isn't tlssocket kind of TCP? How to send RST on a tls connection?

Node.js version

18

Example code

const tlssocket = require('tls').connect({
    port: 443,
    host: 'www.example.com',
})
.on('secureConnect', () => {
    tlssocket.resetAndDestroy();
});
TypeError [ERR_INVALID_HANDLE_TYPE]: This handle type cannot be sent
    at new NodeError (node:internal/errors:393:5)
    at Socket.resetAndDestroy (node:net:700:13)
    at TLSSocket.<anonymous> (/path/to/test.js)
    at TLSSocket.emit (node:events:513:28)
    at TLSSocket.onConnectSecure (node:_tls_wrap:1576:10)
    at TLSSocket.emit (node:events:513:28)
    at TLSSocket._finishInit (node:_tls_wrap:952:8)
    at ssl.onhandshakedone (node:_tls_wrap:733:12)

Operating system

Not applicable.

Scope

runtime

Module and version

net tls

@pinko-fowle
Copy link

Facing the same challenge, I rearchitected my code some to create the socket;

    let client;
    const socket = net.connect(connectOpts, () => {
      client = new tls.TLSSocket(socket);
      // [more code goes here]
    });

In general it'd be Pretty Cool IMHO if the underlying socket were acessible.

I thought for a second maybe tlssocket._handle._parent was gonna be the TCP socket, but it's some other TCP object instead.

@preveen-stack
Copy link
Contributor

@nodejs/net PTAL

@preveen-stack preveen-stack added the question Issues that look for answers. label Aug 25, 2023
@mcollina
Copy link
Member

mcollina commented Sep 4, 2023

This looks like a bug in Node.js. this._handle in that case is a TLSWrap, which looks correct. Therefore I'm not sure how that could work at all.

@mcollina mcollina transferred this issue from nodejs/help Sep 4, 2023
@mcollina mcollina added the confirmed-bug Issues with confirmed bugs. label Sep 4, 2023
@mcollina
Copy link
Member

mcollina commented Sep 4, 2023

cc @nodejs/crypto as well

@preveen-stack preveen-stack removed the question Issues that look for answers. label Sep 4, 2023
@nromito
Copy link

nromito commented May 14, 2024

Running into this bug as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants