Skip to content

Commit 790acc8

Browse files
authored
tls: move IP-address servername deprecation to eol
Has been deprecated for six years. It's time to remove it. PR-URL: #58533 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Dario Piotrowicz <dario.piotrowicz@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent 411cc42 commit 790acc8

File tree

4 files changed

+31
-53
lines changed

4 files changed

+31
-53
lines changed

doc/api/deprecations.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2608,15 +2608,18 @@ Please use `Server.prototype.setSecureContext()` instead.
26082608

26092609
<!-- YAML
26102610
changes:
2611+
- version: REPLACEME
2612+
pr-url: https://github.com/nodejs/node/pull/58533
2613+
description: End-of-Life.
26112614
- version: v12.0.0
26122615
pr-url: https://github.com/nodejs/node/pull/23329
26132616
description: Runtime deprecation.
26142617
-->
26152618

2616-
Type: Runtime
2619+
Type: End-of-Life
26172620

26182621
Setting the TLS ServerName to an IP address is not permitted by
2619-
[RFC 6066][]. This will be ignored in a future version.
2622+
[RFC 6066][].
26202623

26212624
### DEP0124: using `REPLServer.rli`
26222625

lib/internal/tls/wrap.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ const kIsVerified = Symbol('verified');
112112

113113
const noop = () => {};
114114

115-
let ipServernameWarned = false;
116115
let tlsTracingWarned = false;
117116

118117
// Server side times how long a handshake is taking to protect against slow
@@ -1715,6 +1714,14 @@ exports.connect = function connect(...args) {
17151714

17161715
const context = options.secureContext || tls.createSecureContext(options);
17171716

1717+
if (options.servername && net.isIP(options.servername)) {
1718+
throw new ERR_INVALID_ARG_VALUE(
1719+
'options.servername',
1720+
options.servername,
1721+
'Setting the TLS ServerName to an IP address is not permitted.',
1722+
);
1723+
}
1724+
17181725
const tlssock = new TLSSocket(options.socket, {
17191726
allowHalfOpen: options.allowHalfOpen,
17201727
pipe: !!options.path,
@@ -1760,15 +1767,6 @@ exports.connect = function connect(...args) {
17601767
tlssock.setSession(options.session);
17611768

17621769
if (options.servername) {
1763-
if (!ipServernameWarned && net.isIP(options.servername)) {
1764-
process.emitWarning(
1765-
'Setting the TLS ServerName to an IP address is not permitted by ' +
1766-
'RFC 6066. This will be ignored in a future version.',
1767-
'DeprecationWarning',
1768-
'DEP0123',
1769-
);
1770-
ipServernameWarned = true;
1771-
}
17721770
tlssock.setServername(options.servername);
17731771
}
17741772

test/parallel/test-tls-ip-servername-deprecation.js

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const { throws } = require('assert');
5+
6+
if (!common.hasCrypto)
7+
common.skip('missing crypto');
8+
9+
const tls = require('tls');
10+
11+
// Verify that passing an IP address the the servername option
12+
// throws an error.
13+
throws(() => tls.connect({
14+
port: 1234,
15+
servername: '127.0.0.1',
16+
}, common.mustNotCall()), {
17+
code: 'ERR_INVALID_ARG_VALUE',
18+
});

0 commit comments

Comments
 (0)