tls: do not call SNICallback unless present
authorFedor Indutny <fedor.indutny@gmail.com>
Thu, 6 Mar 2014 22:25:38 +0000 (02:25 +0400)
committerFedor Indutny <fedor.indutny@gmail.com>
Thu, 27 Mar 2014 19:26:52 +0000 (23:26 +0400)
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
test/simple/test-tls-session-cache.js

index 92a649b..941bc70 100644 (file)
@@ -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);
index a60ff94..d5db30c 100644 (file)
@@ -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'