From 3058ad0a10c09e5d633ea42e59bce5c2d8fa338c Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Mon, 27 Apr 2015 09:39:48 +0200 Subject: [PATCH] tls: destroy singleUse context immediately Destroy singleUse context right after it is going out of use. Fix: https://github.com/iojs/io.js/issues/1522 --- lib/_tls_common.js | 4 +++- lib/_tls_wrap.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) 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 2785f8d8ba4028..c4467575ec5b3d 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.singleeUse) + this.ssl._secureContext.close(); }; TLSSocket.prototype._init = function(socket, wrap) {