Skip to content

Commit

Permalink
tls: destroy TLS socket if StreamWrap is destroyed
Browse files Browse the repository at this point in the history
Previously, there was no mechanism in place that would
have destroyed the TLS socket once the underlying socket
had been closed.

PR-URL: #24290
Refs: #24288
Refs: #24075
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Ouyang Yadong <oyydoibh@gmail.com>
  • Loading branch information
addaleax committed Nov 16, 2018
1 parent cbbf64e commit b92d55f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,12 @@ function TLSSocket(socket, opts) {

// Wrap plain JS Stream into StreamWrap
var wrap;
if ((socket instanceof net.Socket && socket._handle) || !socket)
if ((socket instanceof net.Socket && socket._handle) || !socket) {
wrap = socket;
else
} else {
wrap = new StreamWrap(socket);
wrap.once('close', () => this.destroy());
}

// Just a documented property to make secure sockets
// distinguishable from regular ones.
Expand Down

0 comments on commit b92d55f

Please sign in to comment.