Skip to content

Commit 26a3cf0

Browse files
danbevcodebytere
authored andcommittedJun 18, 2020
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 a14e38a commit 26a3cf0

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
@@ -170,6 +170,11 @@
170170
"e.g. /root/x/y.js will be referenced via require('root/x/y'). "
171171
"Can be used multiple times")
172172

173+
parser.add_option('--openssl-default-cipher-list',
174+
action='store',
175+
dest='openssl_default_cipher_list',
176+
help='Use the specified cipher list as the default cipher list')
177+
173178
parser.add_option("--openssl-no-asm",
174179
action="store_true",
175180
dest="openssl_no_asm",
@@ -1302,6 +1307,8 @@ def without_ssl_error(option):
13021307
without_ssl_error('--openssl-no-asm')
13031308
if options.openssl_fips:
13041309
without_ssl_error('--openssl-fips')
1310+
if options.openssl_default_cipher_list:
1311+
without_ssl_error('--openssl-default-cipher-list')
13051312
return
13061313

13071314
if options.use_openssl_ca_store:
@@ -1311,6 +1318,9 @@ def without_ssl_error(option):
13111318
variables['node_without_node_options'] = b(options.without_node_options)
13121319
if options.without_node_options:
13131320
o['defines'] += ['NODE_WITHOUT_NODE_OPTIONS']
1321+
if options.openssl_default_cipher_list:
1322+
variables['openssl_default_cipher_list'] = \
1323+
options.openssl_default_cipher_list
13141324

13151325
if not options.shared_openssl and not options.openssl_no_asm:
13161326
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
@@ -269,33 +269,36 @@ Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
269269

270270
## Modifying the Default TLS Cipher suite
271271

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

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

‎node.gyp

+6
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,7 @@
746746

747747
'variables': {
748748
'openssl_system_ca_path%': '',
749+
'openssl_default_cipher_list%': '',
749750
},
750751

751752
'defines': [
@@ -762,6 +763,11 @@
762763
'msvs_disabled_warnings!': [4244],
763764

764765
'conditions': [
766+
[ 'openssl_default_cipher_list!=""', {
767+
'defines': [
768+
'NODE_OPENSSL_DEFAULT_CIPHER_LIST="<(openssl_default_cipher_list)"'
769+
]
770+
}],
765771
[ 'error_on_warn=="true"', {
766772
'cflags': ['-Werror'],
767773
'xcode_settings': {

‎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)
Please sign in to comment.