Skip to content

Commit 3058ad0

Browse files
committed
tls: destroy singleUse context immediately
Destroy singleUse context right after it is going out of use. Fix: #1522
1 parent e431a20 commit 3058ad0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/_tls_common.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@ exports.createSecureContext = function createSecureContext(options, context) {
134134
}
135135

136136
// Do not keep read/write buffers in free list
137-
if (options.singleUse)
137+
if (options.singleUse) {
138+
c.singleUse = true;
138139
c.context.setFreeListLength(0);
140+
}
139141

140142
return c;
141143
};

lib/_tls_wrap.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,9 @@ TLSSocket.prototype._wrapHandle = function(handle) {
301301
};
302302

303303
TLSSocket.prototype._destroySSL = function _destroySSL() {
304-
return this.ssl.destroySSL();
304+
this.ssl.destroySSL();
305+
if (this.ssl._secureContext.singleeUse)
306+
this.ssl._secureContext.close();
305307
};
306308

307309
TLSSocket.prototype._init = function(socket, wrap) {

0 commit comments

Comments
 (0)