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

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

Closed
dieulot opened this issue Jul 23, 2022 · 1 comment · Fixed by #44021
Closed

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

dieulot opened this issue Jul 23, 2022 · 1 comment · Fixed by #44021
Labels
tls Issues and PRs related to the tls subsystem.

Comments

@dieulot
Copy link

dieulot commented Jul 23, 2022

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.

@daeyeon daeyeon added the tls Issues and PRs related to the tls subsystem. label Jul 24, 2022
@theanarkh
Copy link
Contributor

I think because the socket is destroyed so can not get address info from it.

nodejs-github-bot pushed a commit that referenced this issue Aug 1, 2022
On the 'tlsClientError' event, the `tlsSocket` instance is passed as
`closed` status. Thus, users can't get information such as `remote
address`, `remoteFamily`, and so on.

This adds a flag to close a socket after emitting an `error` event.

Signed-off-by: Daeyeon Jeong [email protected]
PR-URL: #44021
Fixes: #43963
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
danielleadams pushed a commit that referenced this issue Aug 16, 2022
On the 'tlsClientError' event, the `tlsSocket` instance is passed as
`closed` status. Thus, users can't get information such as `remote
address`, `remoteFamily`, and so on.

This adds a flag to close a socket after emitting an `error` event.

Signed-off-by: Daeyeon Jeong [email protected]
PR-URL: #44021
Fixes: #43963
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
ruyadorno pushed a commit that referenced this issue Aug 23, 2022
On the 'tlsClientError' event, the `tlsSocket` instance is passed as
`closed` status. Thus, users can't get information such as `remote
address`, `remoteFamily`, and so on.

This adds a flag to close a socket after emitting an `error` event.

Signed-off-by: Daeyeon Jeong [email protected]
PR-URL: #44021
Fixes: #43963
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Fyko pushed a commit to Fyko/node that referenced this issue Sep 15, 2022
On the 'tlsClientError' event, the `tlsSocket` instance is passed as
`closed` status. Thus, users can't get information such as `remote
address`, `remoteFamily`, and so on.

This adds a flag to close a socket after emitting an `error` event.

Signed-off-by: Daeyeon Jeong [email protected]
PR-URL: nodejs#44021
Fixes: nodejs#43963
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
targos pushed a commit that referenced this issue Sep 16, 2022
On the 'tlsClientError' event, the `tlsSocket` instance is passed as
`closed` status. Thus, users can't get information such as `remote
address`, `remoteFamily`, and so on.

This adds a flag to close a socket after emitting an `error` event.

Signed-off-by: Daeyeon Jeong [email protected]
PR-URL: #44021
Fixes: #43963
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
juanarbol pushed a commit that referenced this issue Oct 10, 2022
On the 'tlsClientError' event, the `tlsSocket` instance is passed as
`closed` status. Thus, users can't get information such as `remote
address`, `remoteFamily`, and so on.

This adds a flag to close a socket after emitting an `error` event.

Signed-off-by: Daeyeon Jeong [email protected]
PR-URL: #44021
Fixes: #43963
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
juanarbol pushed a commit that referenced this issue Oct 11, 2022
On the 'tlsClientError' event, the `tlsSocket` instance is passed as
`closed` status. Thus, users can't get information such as `remote
address`, `remoteFamily`, and so on.

This adds a flag to close a socket after emitting an `error` event.

Signed-off-by: Daeyeon Jeong [email protected]
PR-URL: #44021
Fixes: #43963
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
guangwong pushed a commit to noslate-project/node that referenced this issue Jan 3, 2023
On the 'tlsClientError' event, the `tlsSocket` instance is passed as
`closed` status. Thus, users can't get information such as `remote
address`, `remoteFamily`, and so on.

This adds a flag to close a socket after emitting an `error` event.

Signed-off-by: Daeyeon Jeong [email protected]
PR-URL: nodejs/node#44021
Fixes: nodejs/node#43963
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
guangwong pushed a commit to noslate-project/node that referenced this issue Jan 3, 2023
On the 'tlsClientError' event, the `tlsSocket` instance is passed as
`closed` status. Thus, users can't get information such as `remote
address`, `remoteFamily`, and so on.

This adds a flag to close a socket after emitting an `error` event.

Signed-off-by: Daeyeon Jeong [email protected]
PR-URL: nodejs/node#44021
Fixes: nodejs/node#43963
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tls Issues and PRs related to the tls subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants