From d24946b1b45494df1c9a5ff4f80a8eb1d3acf968 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Fri, 7 Mar 2014 02:25:38 +0400 Subject: [PATCH] tls: do not call SNICallback unless present When asynchronously parsing ClientHello for session resumption - SNICallback may not be set. Check if it is present before invoking it. fix #7010 --- lib/_tls_wrap.js | 4 +++- test/simple/test-tls-session-cache.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 92a649bc94..941bc70022 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -104,7 +104,9 @@ function onclienthello(hello) { // session. // // Therefore we should account session loading when dealing with servername - if (ret && ret.servername) { + if (!self._SNICallback) { + self.ssl.endParser(); + } else if (ret && ret.servername) { self._SNICallback(ret.servername, onSNIResult); } else if (hello.servername && self._SNICallback) { self._SNICallback(hello.servername, onSNIResult); diff --git a/test/simple/test-tls-session-cache.js b/test/simple/test-tls-session-cache.js index a60ff949c4..d5db30ce11 100644 --- a/test/simple/test-tls-session-cache.js +++ b/test/simple/test-tls-session-cache.js @@ -90,6 +90,7 @@ function doTest(testOptions, callback) { 's_client', '-tls1', '-connect', 'localhost:' + common.PORT, + '-servername', 'ohgod', '-key', join(common.fixturesDir, 'agent.key'), '-cert', join(common.fixturesDir, 'agent.crt'), '-reconnect'