@@ -445,6 +445,47 @@ The first three are enabled by default. The two `CCM`-based suites are supported
445
445
by TLSv1.3 because they may be more performant on constrained systems, but they
446
446
are not enabled by default since they offer less security.
447
447
448
+ ## OpenSSL security level
449
+
450
+ The OpenSSL library enforces security levels to control the minimum acceptable
451
+ level of security for cryptographic operations. OpenSSL's security levels range
452
+ from 0 to 5, with each level imposing stricter security requirements. The default
453
+ security level is 1, which is generally suitable for most modern applications.
454
+ However, some legacy features and protocols, such as TLSv1, require a lower
455
+ security level (` SECLEVEL=0 ` ) to function properly. For more detailed information,
456
+ please refer to the [ OpenSSL documentation on security levels] [ ] .
457
+
458
+ ### Setting security levels
459
+
460
+ To adjust the security level in your Node.js application, you can include ` @SECLEVEL=X `
461
+ within a cipher string, where ` X ` is the desired security level. For example,
462
+ to set the security level to 0 while using the default OpenSSL cipher list, you could use:
463
+
464
+ ``` js
465
+ const tls = require (' node:tls' );
466
+ const port = 443 ;
467
+
468
+ tls .createServer ({ciphers: ' DEFAULT@SECLEVEL=0' , minVersion: ' TLSv1' }, function (socket ) {
469
+ console .log (' Client connected with protocol:' , socket .getProtocol ());
470
+ socket .end ();
471
+ this .close ();
472
+ }).
473
+ listen (port, () => {
474
+ tls .connect (port, {ciphers: ' DEFAULT@SECLEVEL=0' , maxVersion: ' TLSv1' });
475
+ });
476
+ ```
477
+
478
+ This approach sets the security level to 0, allowing the use of legacy features while still
479
+ leveraging the default OpenSSL ciphers.
480
+
481
+ ### Using [ ` --tls-cipher-list ` ] [ ]
482
+
483
+ You can also set the security level and ciphers from the command line using the
484
+ ` --tls-cipher-list=DEFAULT@SECLEVEL=X ` as described in [ Modifying the default TLS cipher suite] [ ] .
485
+ However, it is generally discouraged to use the command line option for setting ciphers and it is
486
+ preferable to configure the ciphers for individual contexts within your application code,
487
+ as this approach provides finer control and reduces the risk of globally downgrading the security level.
488
+
448
489
## X509 certificate error codes
449
490
450
491
Multiple functions can fail due to certificate errors that are reported by
@@ -1932,7 +1973,7 @@ changes:
1932
1973
of ` 'TLSv1.3' ` , ` 'TLSv1.2' ` , ` 'TLSv1.1' ` , or ` 'TLSv1' ` . Cannot be specified
1933
1974
along with the ` secureProtocol ` option; use one or the other. Avoid
1934
1975
setting to less than TLSv1.2, but it may be required for
1935
- interoperability.
1976
+ interoperability. Versions before TLSv1.2 may require downgrading the [ OpenSSL Security Level ] [ ] .
1936
1977
** Default:** [ ` tls.DEFAULT_MIN_VERSION ` ] [ ] .
1937
1978
* ` passphrase ` {string} Shared passphrase used for a single private key and/or
1938
1979
a PFX.
@@ -2263,6 +2304,7 @@ added: v11.4.0
2263
2304
* {string} The default value of the ` minVersion ` option of
2264
2305
[ ` tls.createSecureContext() ` ] [ ] . It can be assigned any of the supported TLS
2265
2306
protocol versions, ` 'TLSv1.3' ` , ` 'TLSv1.2' ` , ` 'TLSv1.1' ` , or ` 'TLSv1' ` .
2307
+ Versions before TLSv1.2 may require downgrading the [ OpenSSL Security Level] [ ] .
2266
2308
** Default:** ` 'TLSv1.2' ` , unless changed using CLI options. Using
2267
2309
` --tls-min-v1.0 ` sets the default to ` 'TLSv1' ` . Using ` --tls-min-v1.1 ` sets
2268
2310
the default to ` 'TLSv1.1' ` . Using ` --tls-min-v1.3 ` sets the default to
@@ -2291,6 +2333,8 @@ added:
2291
2333
[ Mozilla's publicly trusted list of CAs ] : https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt
2292
2334
[ OCSP request ] : https://en.wikipedia.org/wiki/OCSP_stapling
2293
2335
[ OpenSSL Options ] : crypto.md#openssl-options
2336
+ [ OpenSSL Security Level ] : #openssl-security-level
2337
+ [ OpenSSL documentation on security levels ] : https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_security_level.html#DEFAULT-CALLBACK-BEHAVIOUR
2294
2338
[ Pre-shared keys ] : #pre-shared-keys
2295
2339
[ RFC 2246 ] : https://www.ietf.org/rfc/rfc2246.txt
2296
2340
[ RFC 4086 ] : https://tools.ietf.org/html/rfc4086
0 commit comments