From b70eec8f7bdaa66c3af1babd1469600ad1260c22 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Tue, 5 Jan 2016 22:42:32 -0500 Subject: [PATCH] tls_legacy: do not read on OpenSSL's stack Do not attempt to read data from the socket whilst on OpenSSL's stack, weird things may happen, and this is most likely going to result in some kind of error. PR-URL: https://github.com/nodejs/node/pull/4624 Reviewed-By: Trevor Norris Reviewed-By: James M Snell --- lib/_tls_legacy.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/_tls_legacy.js b/lib/_tls_legacy.js index 8c079e341b5b05..36b4f8bb16d6bc 100644 --- a/lib/_tls_legacy.js +++ b/lib/_tls_legacy.js @@ -614,13 +614,15 @@ function onclienthello(hello) { if (err) return self.socket.destroy(err); - self.ssl.loadSession(session); - self.ssl.endParser(); + setImmediate(function() { + self.ssl.loadSession(session); + self.ssl.endParser(); - // Cycle data - self._resumingSession = false; - self.cleartext.read(0); - self.encrypted.read(0); + // Cycle data + self._resumingSession = false; + self.cleartext.read(0); + self.encrypted.read(0); + }); } if (hello.sessionId.length <= 0 ||