diff --git a/lib/_tls_common.js b/lib/_tls_common.js index 3040b3a5b40c9f..d857717dabae15 100644 --- a/lib/_tls_common.js +++ b/lib/_tls_common.js @@ -134,8 +134,10 @@ exports.createSecureContext = function createSecureContext(options, context) { } // Do not keep read/write buffers in free list - if (options.singleUse) + if (options.singleUse) { + c.singleUse = true; c.context.setFreeListLength(0); + } return c; }; diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index d4774312dcad6a..deb9b5ae6bfa8e 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -301,7 +301,9 @@ TLSSocket.prototype._wrapHandle = function(handle) { }; TLSSocket.prototype._destroySSL = function _destroySSL() { - return this.ssl.destroySSL(); + this.ssl.destroySSL(); + if (this.ssl._secureContext.singleUse) + this.ssl._secureContext.context.close(); }; TLSSocket.prototype._init = function(socket, wrap) {