tls: prevent multiple connection errors
onConnectEnd(), which is called by TLSSocket, has a guard to prevent being called multiple times, but it does not prevent the OpenSSL error handler from being called, leading to multiple error events. This commit adds that piece of missing logic. PR-URL: https://github.com/nodejs/node/pull/23636 Fixes: https://github.com/nodejs/node/issues/23631 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Wyatt Preul <wpreul@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
e2f58c71dd
commit
b94ce575f5
@ -248,9 +248,11 @@ function onocspresponse(resp) {
|
|||||||
function onerror(err) {
|
function onerror(err) {
|
||||||
const owner = this[owner_symbol];
|
const owner = this[owner_symbol];
|
||||||
|
|
||||||
if (owner._writableState.errorEmitted)
|
if (owner._hadError)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
owner._hadError = true;
|
||||||
|
|
||||||
// Destroy socket if error happened before handshake's finish
|
// Destroy socket if error happened before handshake's finish
|
||||||
if (!owner._secureEstablished) {
|
if (!owner._secureEstablished) {
|
||||||
// When handshake fails control is not yet released,
|
// When handshake fails control is not yet released,
|
||||||
@ -265,8 +267,6 @@ function onerror(err) {
|
|||||||
// Throw error
|
// Throw error
|
||||||
owner._emitTLSError(err);
|
owner._emitTLSError(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
owner._writableState.errorEmitted = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initRead(tls, wrapped) {
|
function initRead(tls, wrapped) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user