Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tls: provide default cipher list from command line #32760

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/crypto.js
Expand Up @@ -25,6 +25,7 @@
'use strict';

const {
ObjectDefineProperty,
ObjectDefineProperties,
} = primordials;

Expand Down Expand Up @@ -224,6 +225,10 @@ function getFipsForced() {
return 1;
}

ObjectDefineProperty(constants, 'defaultCipherList', {
value: getOptionValue('--tls-cipher-list')
});

ObjectDefineProperties(module.exports, {
createCipher: {
enumerable: false,
Expand Down
3 changes: 1 addition & 2 deletions lib/tls.js
Expand Up @@ -56,8 +56,7 @@ const _tls_wrap = require('_tls_wrap');
exports.CLIENT_RENEG_LIMIT = 3;
exports.CLIENT_RENEG_WINDOW = 600;

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

exports.DEFAULT_ECDH_CURVE = 'auto';

Expand Down
6 changes: 0 additions & 6 deletions src/node_constants.cc
Expand Up @@ -1072,12 +1072,6 @@ void DefineCryptoConstants(Local<Object> target) {
NODE_DEFINE_CONSTANT(target, POINT_CONVERSION_UNCOMPRESSED);

NODE_DEFINE_CONSTANT(target, POINT_CONVERSION_HYBRID);

NODE_DEFINE_STRING_CONSTANT(
target,
"defaultCipherList",
per_process::cli_options->tls_cipher_list.c_str());

#endif
}

Expand Down
10 changes: 6 additions & 4 deletions test/parallel/test-tls-cipher-list.js
Expand Up @@ -8,11 +8,11 @@ const assert = require('assert');
const spawn = require('child_process').spawn;
const defaultCoreList = require('crypto').constants.defaultCoreCipherList;

function doCheck(arg, check) {
function doCheck(arg, expression, check) {
let out = '';
arg = arg.concat([
'-pe',
'require("crypto").constants.defaultCipherList'
expression
]);
spawn(process.execPath, arg, {})
.on('error', common.mustNotCall())
Expand All @@ -24,7 +24,9 @@ function doCheck(arg, check) {
}

// Test the default unmodified version
doCheck([], defaultCoreList);
doCheck([], 'crypto.constants.defaultCipherList', defaultCoreList);
doCheck([], 'tls.DEFAULT_CIPHERS', defaultCoreList);

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