tls: do not default to 'localhost' servername
authorFedor Indutny <fedor.indutny@gmail.com>
Mon, 28 Oct 2013 12:10:10 +0000 (16:10 +0400)
committerFedor Indutny <fedor.indutny@gmail.com>
Wed, 30 Oct 2013 21:57:20 +0000 (01:57 +0400)
lib/_tls_wrap.js
src/node_crypto.cc

index a09b5aa..98768eb 100644 (file)
@@ -685,8 +685,7 @@ exports.connect = function(/* [port, host], options, cb */) {
 
   var hostname = options.servername ||
                  options.host ||
-                 options.socket && options.socket._host ||
-                 'localhost',
+                 options.socket && options.socket._host,
       NPN = {},
       credentials = crypto.createCredentials(options);
   tls.convertNPNProtocols(options.NPNProtocols, NPN);
index 46e6a92..c885cb8 100644 (file)
@@ -1710,7 +1710,7 @@ void Connection::New(const FunctionCallbackInfo<Value>& args) {
 #ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
   if (is_server) {
     SSL_CTX_set_tlsext_servername_callback(sc->ctx_, SelectSNIContextCallback_);
-  } else {
+  } else if (args[2]->IsString()) {
     const String::Utf8Value servername(args[2]);
     SSL_set_tlsext_host_name(conn->ssl_, *servername);
   }