Skip to content

resetAndDestroy can not be called on tlssocket? #49484

Description

@LongTengDao

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

Activity

  1. pinko-fowle commented on May 12, 2023

    @pinko-fowle

    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.

  2. preveen-stack commented on Aug 25, 2023

    @preveen-stack
    Contributor

    @nodejs/net PTAL

  3. mcollina commented on Sep 4, 2023

    @mcollina
    SponsorMember

    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.

  4. transferred this issue fromnodejs/helpon Sep 4, 2023
  5. mcollina commented on Sep 4, 2023

    @mcollina
    SponsorMember

    cc @nodejs/crypto as well

  6. nromito commented on May 14, 2024

    @nromito

    Running into this bug as well

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions