Skip to content

Commit bdabf69

Browse files
sam-githubtargos
authored andcommitted
tls: add --tls-min-v1.2 CLI switch
Switch added in v11.x, add it to master/12.x for consistency and compatibility. See: #26951, commit bf2c283 PR-URL: #27520 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]>
1 parent 55804e1 commit bdabf69

File tree

6 files changed

+35
-0
lines changed

6 files changed

+35
-0
lines changed

doc/api/cli.md

+9
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,15 @@ added: v12.0.0
586586
Set default [`tls.DEFAULT_MIN_VERSION`][] to 'TLSv1.1'. Use for compatibility
587587
with old TLS clients or servers.
588588

589+
### `--tls-min-v1.2`
590+
<!-- YAML
591+
added: REPLACEME
592+
-->
593+
594+
Set default [`tls.DEFAULT_MIN_VERSION`][] to 'TLSv1.2'. This is the default for
595+
12.x and later, but the option is supported for compatibility with older Node.js
596+
versions.
597+
589598
### `--tls-min-v1.3`
590599
<!-- YAML
591600
added: v12.0.0

doc/node.1

+4
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ or servers.
278278
Set default minVersion to 'TLSv1.1'. Use for compatibility with old TLS clients
279279
or servers.
280280
.
281+
.It Fl -tls-min-v1.2
282+
Set default minVersion to 'TLSv1.2'. This is the default for 12.x and later,
283+
but the option is supported for compatibility with older Node.js versions.
284+
.
281285
.It Fl -tls-min-v1.3
282286
Set default minVersion to 'TLSv1.3'. Use to disable support for TLSv1.2 in
283287
favour of TLSv1.3, which is more secure.

lib/tls.js

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ if (getOptionValue('--tls-min-v1.0'))
6060
exports.DEFAULT_MIN_VERSION = 'TLSv1';
6161
else if (getOptionValue('--tls-min-v1.1'))
6262
exports.DEFAULT_MIN_VERSION = 'TLSv1.1';
63+
else if (getOptionValue('--tls-min-v1.2'))
64+
exports.DEFAULT_MIN_VERSION = 'TLSv1.2';
6365
else if (getOptionValue('--tls-min-v1.3'))
6466
exports.DEFAULT_MIN_VERSION = 'TLSv1.3';
6567
else

src/node_options.cc

+4
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,10 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
433433
"set default TLS minimum to TLSv1.1 (default: TLSv1.2)",
434434
&EnvironmentOptions::tls_min_v1_1,
435435
kAllowedInEnvironment);
436+
AddOption("--tls-min-v1.2",
437+
"set default TLS minimum to TLSv1.2 (default: TLSv1.2)",
438+
&EnvironmentOptions::tls_min_v1_2,
439+
kAllowedInEnvironment);
436440
AddOption("--tls-min-v1.3",
437441
"set default TLS minimum to TLSv1.3 (default: TLSv1.2)",
438442
&EnvironmentOptions::tls_min_v1_3,

src/node_options.h

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class EnvironmentOptions : public Options {
134134

135135
bool tls_min_v1_0 = false;
136136
bool tls_min_v1_1 = false;
137+
bool tls_min_v1_2 = false;
137138
bool tls_min_v1_3 = false;
138139
bool tls_max_v1_2 = false;
139140
bool tls_max_v1_3 = false;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Flags: --tls-min-v1.2
2+
'use strict';
3+
const common = require('../common');
4+
if (!common.hasCrypto) common.skip('missing crypto');
5+
6+
// Check that node `--tls-min-v1.2` is supported.
7+
8+
const assert = require('assert');
9+
const tls = require('tls');
10+
11+
assert.strictEqual(tls.DEFAULT_MAX_VERSION, 'TLSv1.3');
12+
assert.strictEqual(tls.DEFAULT_MIN_VERSION, 'TLSv1.2');
13+
14+
// Check the min-max version protocol versions against these CLI settings.
15+
require('./test-tls-min-max-version.js');

0 commit comments

Comments
 (0)