Skip to content

Commit 8f46991

Browse files
committed
squash! add --tls-v1.0 and --tls-v1.1 flags
1 parent ff8f6e3 commit 8f46991

File tree

8 files changed

+50
-6
lines changed

8 files changed

+50
-6
lines changed

doc/api/cli.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,22 @@ added: v4.0.0
323323
Specify an alternative default TLS cipher list. Requires Node.js to be built
324324
with crypto support (default).
325325

326+
### `--tls-v1.0`
327+
<!-- YAML
328+
added: REPLACEME
329+
-->
330+
331+
Enable TLSv1.0. This should only be used for compatibility with old TLS
332+
clients or servers.
333+
334+
### `--tls-v1.1`
335+
<!-- YAML
336+
added: REPLACEME
337+
-->
338+
339+
Enable TLSv1.1. This should only be used for compatibility with old TLS
340+
clients or servers.
341+
326342
### `--trace-deprecation`
327343
<!-- YAML
328344
added: v0.8.0

doc/node.1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ Specify process.title on startup.
183183
Specify an alternative default TLS cipher list.
184184
Requires Node.js to be built with crypto support. (Default)
185185
.
186+
.It Fl -tls-v1.0
187+
Enable TLSv1.0. This should only be used for compatibility with old TLS
188+
clients or servers.
189+
.
190+
.It Fl -tls-v1.1
191+
Enable TLSv1.1. This should only be used for compatibility with old TLS
192+
clients or servers.
193+
.
186194
.It Fl -trace-deprecation
187195
Print stack traces for deprecations.
188196
.

src/node_crypto.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
400400
int max_version = 0;
401401
const SSL_METHOD* method = TLS_method();
402402

403+
if (env->options()->tls_v1_1) min_version = TLS1_1_VERSION;
404+
if (env->options()->tls_v1_0) min_version = TLS1_VERSION;
405+
403406
if (args.Length() == 1 && args[0]->IsString()) {
404407
const node::Utf8Value sslmethod(env->isolate(), args[0]);
405408

src/node_options.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,17 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
189189

190190
AddOption("--napi-modules", "", NoOp{}, kAllowedInEnvironment);
191191

192+
#if HAVE_OPENSSL
193+
AddOption("--tls-v1.0",
194+
"enable TLSv1.0",
195+
&EnvironmentOptions::tls_v1_0,
196+
kAllowedInEnvironment);
197+
AddOption("--tls-v1.1",
198+
"enable TLSv1.1",
199+
&EnvironmentOptions::tls_v1_1,
200+
kAllowedInEnvironment);
201+
#endif
202+
192203
Insert(&DebugOptionsParser::instance,
193204
&EnvironmentOptions::get_debug_options);
194205
}

src/node_options.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ class EnvironmentOptions : public Options {
9292
bool print_eval = false;
9393
bool force_repl = false;
9494

95+
#if HAVE_OPENSSL
96+
bool tls_v1_0 = false;
97+
bool tls_v1_1 = false;
98+
#endif
99+
95100
std::vector<std::string> preload_modules;
96101

97102
std::vector<std::string> user_argv;

test/parallel/test-https-agent-additional-options.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Flags: --tls-v1.1
12
'use strict';
23
const common = require('../common');
34
if (!common.hasCrypto)
@@ -11,8 +12,7 @@ const fixtures = require('../common/fixtures');
1112
const options = {
1213
key: fixtures.readKey('agent1-key.pem'),
1314
cert: fixtures.readKey('agent1-cert.pem'),
14-
ca: fixtures.readKey('ca1-cert.pem'),
15-
secureProtocol: 'TLS_method',
15+
ca: fixtures.readKey('ca1-cert.pem')
1616
};
1717

1818
const server = https.Server(options, function(req, res) {
@@ -35,7 +35,7 @@ const updatedValues = new Map([
3535
['ecdhCurve', 'secp384r1'],
3636
['honorCipherOrder', true],
3737
['secureOptions', crypto.constants.SSL_OP_CIPHER_SERVER_PREFERENCE],
38-
['secureProtocol', 'TLSv1_method'],
38+
['secureProtocol', 'TLSv1_1_method'],
3939
['sessionIdContext', 'sessionIdContext'],
4040
]);
4141

test/parallel/test-https-agent-session-eviction.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Flags: --tls-v1.0
12
'use strict';
23

34
const common = require('../common');
@@ -54,8 +55,7 @@ function faultyServer(port) {
5455
function second(server, session) {
5556
const req = https.request({
5657
port: server.address().port,
57-
rejectUnauthorized: false,
58-
secureProtocol: 'TLS_method',
58+
rejectUnauthorized: false
5959
}, function(res) {
6060
res.resume();
6161
});

test/parallel/test-process-env-allowed-flags.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ require('../common');
5151
// assert all "canonical" flags begin with dash(es)
5252
{
5353
process.allowedNodeEnvironmentFlags.forEach((flag) => {
54-
assert(/^--?[a-z8_-]+$/.test(flag), `Unexpected format for flag ${flag}`);
54+
assert(/^--?[a-z0-9._-]+$/.test(flag),
55+
`Unexpected format for flag ${flag}`);
5556
});
5657
}
5758

0 commit comments

Comments
 (0)