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 authored and targos committed Nov 18, 2018
1 parent b90f2f8 commit 7a54845
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 @@ -308,10 +308,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 7a54845

Please sign in to comment.