Skip to content

Commit

Permalink
tls: emit a warning when servername is an IP address
Browse files Browse the repository at this point in the history
Refs: #18071
  • Loading branch information
Rodger Combs committed Feb 13, 2018
1 parent 6abce37 commit 53957d5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const kSNICallback = Symbol('snicallback');

const noop = () => {};

let ipServernameWarned = false;

function onhandshakestart(now) {
debug('onhandshakestart');

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 53957d5

Please sign in to comment.