Skip to content

Commit 53957d5

Browse files
author
Rodger Combs
committed
tls: emit a warning when servername is an IP address
Refs: nodejs#18071
1 parent 6abce37 commit 53957d5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/_tls_wrap.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ const kSNICallback = Symbol('snicallback');
4848

4949
const noop = () => {};
5050

51+
let ipServernameWarned = false;
52+
5153
function onhandshakestart(now) {
5254
debug('onhandshakestart');
5355

@@ -1152,8 +1154,17 @@ exports.connect = function(...args /* [port,] [host,] [options,] [cb] */) {
11521154
if (options.session)
11531155
socket.setSession(options.session);
11541156

1155-
if (options.servername)
1157+
if (options.servername) {
1158+
if (!ipServernameWarned && net.isIP(options.servername)) {
1159+
process.emitWarning(
1160+
'Setting the TLS ServerName to an IP address is not supported by ' +
1161+
'RFC6066. This will be ignored in a future version.',
1162+
'UnsupportedWarning'
1163+
);
1164+
ipServernameWarned = true;
1165+
}
11561166
socket.setServername(options.servername);
1167+
}
11571168

11581169
if (options.socket)
11591170
socket._start();

0 commit comments

Comments
 (0)