Skip to content

tlsClientError event: tlsSocket.remoteAddress etc. are undefined #43963

Description

@dieulot

Version

v18.6.0

Platform

Darwin AirdeAlexandre 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 x86_64

Subsystem

No response

What steps will reproduce the bug?

Run this:

const https = require('https')

const server = https.createServer()
server.on('tlsClientError', (exception, tlsSocket) => {
  console.log(tlsSocket.address())
  console.log(tlsSocket.localAddress, tlsSocket.localPort)
  console.log(tlsSocket.remoteAddress, tlsSocket.remoteFamily, tlsSocket.remotePort)
  console.log('remoteAddress' in tlsSocket)
})
server.listen(1111)

Trigger it:

curl https://127.0.0.1:1111

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior?

{ address: '::ffff:127.0.0.1', family: 'IPv6', port: 1111 }
::ffff:127.0.0.1 1111
::ffff:127.0.0.1 IPv6 62538
true

What do you see instead?

{}
undefined undefined
undefined undefined undefined
true

Additional information

Use case: Log who’s hitting my server with an incorrect Server Name Indication (SNI) or with no SNI. I don’t think there’s a non-hacky way to do so otherwise.

Also happens in v16.15.1.

Activity

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

    tlsIssues and PRs related to the tls subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions