You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the correct, non-deprecated way to use the new tls.TLSSocket(...) constructor to establish a secure connection? Context: GHSA-2cpx-6pqp-wf35
According to two unmerged docs PRs, when directly calling new tls.TLSSocket(...) it is the user's responsibility to validate peer certificates and identity.
It is important to remember, however,
that it is the caller's responsibility to manage the lifecycle of the provided net.Socket, including establishing the connection and validating peer
certificates and identity. See the ['secure'][] event.
Both PRs demonstrate how to do this validation, but require use of:
The 'secure' event. In the current Node.js documentation, the only mention of 'secure' is under the deprecated tls.SecurePair, and is itself deprecated. It is also not clear that the 'secure' event is also emitted on tls.TLSSocket. https://nodejs.org/docs/latest-v18.x/api/tls.html#event-secure
The current documentation does not indicate that using new tls.TLSSocket(...) by itself does not result in a secure connection.
As far as I can tell it is impossible to use new tls.TLSSocket(...) to establish a secure connection without relying on APIs that are undocumented, deprecated, and/or legacy.
The text was updated successfully, but these errors were encountered:
Affected URL(s)
https://nodejs.org/docs/latest-v18.x/api/tls.html
Description of the problem
What is the correct, non-deprecated way to use the
new tls.TLSSocket(...)
constructor to establish a secure connection? Context: GHSA-2cpx-6pqp-wf35According to two unmerged docs PRs, when directly calling
new tls.TLSSocket(...)
it is the user's responsibility to validate peer certificates and identity.In #10846 it says:
In #23915 it says:
And includes an example:
Both PRs demonstrate how to do this validation, but require use of:
'secure'
event. In the current Node.js documentation, the only mention of'secure'
is under the deprecatedtls.SecurePair
, and is itself deprecated. It is also not clear that the'secure'
event is also emitted ontls.TLSSocket
.https://nodejs.org/docs/latest-v18.x/api/tls.html#event-secure
tlsSocket.ssl.verifyError()
, which does not appear at all in the current documentation. Furthermore, according to TLSCallbacks => TLSWrap, better TLS inception #840 (comment)tlsSocket.ssl
is a "legacy property".Note that the described validation steps appear to be consistent with internal use
node/lib/_tls_wrap.js
Line 1106 in 5fbf33e
node/lib/_tls_wrap.js
Lines 1044 to 1055 in 5fbf33e
This leaves me with two concerns:
new tls.TLSSocket(...)
by itself does not result in a secure connection.new tls.TLSSocket(...)
to establish a secure connection without relying on APIs that are undocumented, deprecated, and/or legacy.The text was updated successfully, but these errors were encountered: