From 91620b8bd61bc7932198c2309b8f3158d04ae4ca Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 5 Mar 2019 15:00:09 +0100 Subject: [PATCH] tls: fix legacy SecurePair session resumption This seems to have been broken ever since its introduction 5 years ago in commit 75ea11fc08 ("tls: introduce asynchronous `newSession`") and no one complained but that's not going to stop me from fixing it anyway because otherwise I can't write a regression test for issue #26428. Refs: https://github.com/nodejs/node/issues/26428 PR-URL: https://github.com/nodejs/node/pull/26452 Fixes: https://github.com/nodejs/node/issues/26428 Reviewed-By: Sam Roberts Reviewed-By: James M Snell Reviewed-By: Beth Griggs --- lib/_tls_legacy.js | 5 +++-- src/env.h | 1 - src/node_crypto.cc | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/_tls_legacy.js b/lib/_tls_legacy.js index fc2fb6db5d12ae..52de70d4794de1 100644 --- a/lib/_tls_legacy.js +++ b/lib/_tls_legacy.js @@ -691,8 +691,9 @@ function onnewsession(key, session) { return; once = true; - if (self.ssl) - self.ssl.newSessionDone(); + // Cycle data + self.cleartext.read(0); + self.encrypted.read(0); } } diff --git a/src/env.h b/src/env.h index e378869b4ccdcb..b47d55d87b3e69 100644 --- a/src/env.h +++ b/src/env.h @@ -216,7 +216,6 @@ class ModuleWrap; V(onheaders_string, "onheaders") \ V(onmessage_string, "onmessage") \ V(onnewsession_string, "onnewsession") \ - V(onnewsessiondone_string, "onnewsessiondone") \ V(onocspresponse_string, "onocspresponse") \ V(ongoawaydata_string, "ongoawaydata") \ V(onorigin_string, "onorigin") \ diff --git a/src/node_crypto.cc b/src/node_crypto.cc index d0e17717d9c2cb..61fefd78b9d970 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -2965,9 +2965,6 @@ void Connection::SetShutdownFlags() { void Connection::NewSessionDoneCb() { - HandleScope scope(env()->isolate()); - - MakeCallback(env()->onnewsessiondone_string(), 0, nullptr); }