Skip to content

Commit abf04b2

Browse files
danbevcodebytere
authored andcommitted
src,build: add --openssl-default-cipher-list
This commit adds a configuration option named openssl-default-cipher-list which takes a colon separated string specifying ciphers that should be used as the default ciphers instead of the ones defined in node_constants. The motivation for this is a use case where Fedora/RHEL would like to be able to specify a default cipher in the format PROFILE=SYSTEM. This would enable Fedora/RHEL to have a system wide security level for all applications. PR-URL: #33708 Refs: https://docs.fedoraproject.org/en-US/packaging-guidelines/CryptoPolicies/ Reviewed-By: David Carlier <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent 5328089 commit abf04b2

File tree

4 files changed

+50
-27
lines changed

4 files changed

+50
-27
lines changed

configure.py

+10
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@
164164
"e.g. /root/x/y.js will be referenced via require('root/x/y'). "
165165
"Can be used multiple times")
166166

167+
parser.add_option('--openssl-default-cipher-list',
168+
action='store',
169+
dest='openssl_default_cipher_list',
170+
help='Use the specified cipher list as the default cipher list')
171+
167172
parser.add_option("--openssl-no-asm",
168173
action="store_true",
169174
dest="openssl_no_asm",
@@ -1286,6 +1291,8 @@ def without_ssl_error(option):
12861291
without_ssl_error('--openssl-no-asm')
12871292
if options.openssl_fips:
12881293
without_ssl_error('--openssl-fips')
1294+
if options.openssl_default_cipher_list:
1295+
without_ssl_error('--openssl-default-cipher-list')
12891296
return
12901297

12911298
if options.use_openssl_ca_store:
@@ -1295,6 +1302,9 @@ def without_ssl_error(option):
12951302
variables['node_without_node_options'] = b(options.without_node_options)
12961303
if options.without_node_options:
12971304
o['defines'] += ['NODE_WITHOUT_NODE_OPTIONS']
1305+
if options.openssl_default_cipher_list:
1306+
variables['openssl_default_cipher_list'] = \
1307+
options.openssl_default_cipher_list
12981308

12991309
if not options.shared_openssl and not options.openssl_no_asm:
13001310
is_x86 = 'x64' in variables['target_arch'] or 'ia32' in variables['target_arch']

doc/api/tls.md

+29-26
Original file line numberDiff line numberDiff line change
@@ -273,33 +273,36 @@ Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
273273

274274
## Modifying the default TLS cipher suite
275275

276-
Node.js is built with a default suite of enabled and disabled TLS ciphers.
277-
Currently, the default cipher suite is:
276+
Node.js is built with a default suite of enabled and disabled TLS ciphers. This
277+
default cipher list can be configured when building Node.js to allow
278+
distributions to provide their own default list.
278279

279-
```text
280-
TLS_AES_256_GCM_SHA384:
281-
TLS_CHACHA20_POLY1305_SHA256:
282-
TLS_AES_128_GCM_SHA256:
283-
ECDHE-RSA-AES128-GCM-SHA256:
284-
ECDHE-ECDSA-AES128-GCM-SHA256:
285-
ECDHE-RSA-AES256-GCM-SHA384:
286-
ECDHE-ECDSA-AES256-GCM-SHA384:
287-
DHE-RSA-AES128-GCM-SHA256:
288-
ECDHE-RSA-AES128-SHA256:
289-
DHE-RSA-AES128-SHA256:
290-
ECDHE-RSA-AES256-SHA384:
291-
DHE-RSA-AES256-SHA384:
292-
ECDHE-RSA-AES256-SHA256:
293-
DHE-RSA-AES256-SHA256:
294-
HIGH:
295-
!aNULL:
296-
!eNULL:
297-
!EXPORT:
298-
!DES:
299-
!RC4:
300-
!MD5:
301-
!PSK:
302-
!SRP:
280+
The following command can be used to show the default cipher suite:
281+
```console
282+
node -p crypto.constants.defaultCoreCipherList | tr ':' '\n'
283+
TLS_AES_256_GCM_SHA384
284+
TLS_CHACHA20_POLY1305_SHA256
285+
TLS_AES_128_GCM_SHA256
286+
ECDHE-RSA-AES128-GCM-SHA256
287+
ECDHE-ECDSA-AES128-GCM-SHA256
288+
ECDHE-RSA-AES256-GCM-SHA384
289+
ECDHE-ECDSA-AES256-GCM-SHA384
290+
DHE-RSA-AES128-GCM-SHA256
291+
ECDHE-RSA-AES128-SHA256
292+
DHE-RSA-AES128-SHA256
293+
ECDHE-RSA-AES256-SHA384
294+
DHE-RSA-AES256-SHA384
295+
ECDHE-RSA-AES256-SHA256
296+
DHE-RSA-AES256-SHA256
297+
HIGH
298+
!aNULL
299+
!eNULL
300+
!EXPORT
301+
!DES
302+
!RC4
303+
!MD5
304+
!PSK
305+
!SRP
303306
!CAMELLIA
304307
```
305308

node.gyp

+6
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@
736736

737737
'variables': {
738738
'openssl_system_ca_path%': '',
739+
'openssl_default_cipher_list%': '',
739740
},
740741

741742
'defines': [
@@ -752,6 +753,11 @@
752753
'msvs_disabled_warnings!': [4244],
753754

754755
'conditions': [
756+
[ 'openssl_default_cipher_list!=""', {
757+
'defines': [
758+
'NODE_OPENSSL_DEFAULT_CIPHER_LIST="<(openssl_default_cipher_list)"'
759+
]
760+
}],
755761
[ 'node_builtin_modules_path!=""', {
756762
'defines': [ 'NODE_BUILTIN_MODULES_PATH="<(node_builtin_modules_path)"' ]
757763
}],

src/node_constants.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
#define RSA_PSS_SALTLEN_AUTO -2
4242
#endif
4343

44+
#if defined(NODE_OPENSSL_DEFAULT_CIPHER_LIST)
45+
#define DEFAULT_CIPHER_LIST_CORE NODE_OPENSSL_DEFAULT_CIPHER_LIST
46+
#else
4447
// TLSv1.3 suites start with TLS_, and are the OpenSSL defaults, see:
4548
// https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_ciphersuites.html
4649
#define DEFAULT_CIPHER_LIST_CORE \
@@ -68,7 +71,8 @@
6871
"!PSK:" \
6972
"!SRP:" \
7073
"!CAMELLIA"
71-
#endif
74+
#endif // NODE_OPENSSL_DEFAULT_CIPHER_LIST
75+
#endif // HAVE_OPENSSL
7276

7377
namespace node {
7478

0 commit comments

Comments
 (0)