Skip to content

Commit 1f9761f

Browse files
committed
tls: provide default cipher list from command line
Avoid storing data that depends on command line options on internal bindings. This is generally a cleaner way of accessing CLI options. PR-URL: nodejs#32760 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>
1 parent bb5e709 commit 1f9761f

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

lib/crypto.js

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
'use strict';
2626

2727
const {
28+
ObjectDefineProperty,
2829
ObjectDefineProperties,
2930
} = primordials;
3031

@@ -224,6 +225,10 @@ function getFipsForced() {
224225
return 1;
225226
}
226227

228+
ObjectDefineProperty(constants, 'defaultCipherList', {
229+
value: getOptionValue('--tls-cipher-list')
230+
});
231+
227232
ObjectDefineProperties(module.exports, {
228233
createCipher: {
229234
enumerable: false,

lib/tls.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ const _tls_wrap = require('_tls_wrap');
5656
exports.CLIENT_RENEG_LIMIT = 3;
5757
exports.CLIENT_RENEG_WINDOW = 600;
5858

59-
exports.DEFAULT_CIPHERS =
60-
internalBinding('constants').crypto.defaultCipherList;
59+
exports.DEFAULT_CIPHERS = getOptionValue('--tls-cipher-list');
6160

6261
exports.DEFAULT_ECDH_CURVE = 'auto';
6362

src/node_constants.cc

-6
Original file line numberDiff line numberDiff line change
@@ -1072,12 +1072,6 @@ void DefineCryptoConstants(Local<Object> target) {
10721072
NODE_DEFINE_CONSTANT(target, POINT_CONVERSION_UNCOMPRESSED);
10731073

10741074
NODE_DEFINE_CONSTANT(target, POINT_CONVERSION_HYBRID);
1075-
1076-
NODE_DEFINE_STRING_CONSTANT(
1077-
target,
1078-
"defaultCipherList",
1079-
per_process::cli_options->tls_cipher_list.c_str());
1080-
10811075
#endif
10821076
}
10831077

test/parallel/test-tls-cipher-list.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const assert = require('assert');
88
const spawn = require('child_process').spawn;
99
const defaultCoreList = require('crypto').constants.defaultCoreCipherList;
1010

11-
function doCheck(arg, check) {
11+
function doCheck(arg, expression, check) {
1212
let out = '';
1313
arg = arg.concat([
1414
'-pe',
15-
'require("crypto").constants.defaultCipherList'
15+
expression
1616
]);
1717
spawn(process.execPath, arg, {})
1818
.on('error', common.mustNotCall())
@@ -24,7 +24,9 @@ function doCheck(arg, check) {
2424
}
2525

2626
// Test the default unmodified version
27-
doCheck([], defaultCoreList);
27+
doCheck([], 'crypto.constants.defaultCipherList', defaultCoreList);
28+
doCheck([], 'tls.DEFAULT_CIPHERS', defaultCoreList);
2829

2930
// Test the command line switch by itself
30-
doCheck(['--tls-cipher-list=ABC'], 'ABC');
31+
doCheck(['--tls-cipher-list=ABC'], 'crypto.constants.defaultCipherList', 'ABC');
32+
doCheck(['--tls-cipher-list=ABC'], 'tls.DEFAULT_CIPHERS', 'ABC');

0 commit comments

Comments
 (0)