From 53957d576d82d8e850decc3e7467b1ac32b2c236 Mon Sep 17 00:00:00 2001 From: Rodger Combs Date: Fri, 12 Jan 2018 17:36:21 -0600 Subject: [PATCH] tls: emit a warning when servername is an IP address Refs: https://github.com/nodejs/node/issues/18071 --- lib/_tls_wrap.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index fcd447bb5901fe..b219b84cc80d75 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -48,6 +48,8 @@ const kSNICallback = Symbol('snicallback'); const noop = () => {}; +let ipServernameWarned = false; + function onhandshakestart(now) { debug('onhandshakestart'); @@ -1152,8 +1154,17 @@ exports.connect = function(...args /* [port,] [host,] [options,] [cb] */) { if (options.session) socket.setSession(options.session); - if (options.servername) + if (options.servername) { + if (!ipServernameWarned && net.isIP(options.servername)) { + process.emitWarning( + 'Setting the TLS ServerName to an IP address is not supported by ' + + 'RFC6066. This will be ignored in a future version.', + 'UnsupportedWarning' + ); + ipServernameWarned = true; + } socket.setServername(options.servername); + } if (options.socket) socket._start();