From d67d65bea7b53a45064bcc0f4c1db68ff3b2882a Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 14 Mar 2016 17:56:02 +0200 Subject: [PATCH] fix: ssl socket leak when keepalive is used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SSL sockets leak whenever keep alive is enabled, ca option is set in the global agent, and requests are sent without the ca property. In the following case at Agent.prototype.createSocket a socket will be created with a hashtag name that includes data from the global agents’ ca property. On subsequent requests at Agent.prototype.addRequest we do not find the free socket, because the hashtag name generated there does not take into account the global agents’ ca property, thus creating a new socket and leaving the first socket to timeout. -closes: #5699 --- lib/_http_agent.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/_http_agent.js b/lib/_http_agent.js index 5828927786288f..fd74daafec6486 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -115,6 +115,9 @@ Agent.prototype.addRequest = function(req, options) { }; } + options = util._extend({}, options); + options = util._extend(options, this.options); + var name = this.getName(options); if (!this.sockets[name]) { this.sockets[name] = [];