Skip to content

Commit

Permalink
tls: prevent multiple connection errors
Browse files Browse the repository at this point in the history
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: #23636
Fixes: #23631
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Wyatt Preul <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
cjihrig authored and MylesBorins committed Oct 30, 2018
1 parent 3ca41dc commit 81dc241
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,11 @@ function onocspresponse(resp) {
function onerror(err) {
const owner = this[owner_symbol];

if (owner._writableState.errorEmitted)
if (owner._hadError)
return;

owner._hadError = true;

// Destroy socket if error happened before handshake's finish
if (!owner._secureEstablished) {
// When handshake fails control is not yet released,
Expand All @@ -267,8 +269,6 @@ function onerror(err) {
// Throw error
owner._emitTLSError(err);
}

owner._writableState.errorEmitted = true;
}

function initRead(tls, wrapped) {
Expand Down

0 comments on commit 81dc241

Please sign in to comment.