Skip to content

Commit ea48c30

Browse files
danbevRafaelGSS
authored andcommitted
src,doc,test: add --openssl-shared-config option
This commit adds a new command line option named '--openssl-shared-config' intended to allow reverting to the old OpenSSL configuration behavior where Node.js would use the configuration section name (called appname in OpenSSL) 'openssl_conf' which could potentially be used my other applications.. PR-URL: #43124 Refs: #40366 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Backport-PR-URL: #43782 Refs: nodejs/nodejs.org#4713 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent de80707 commit ea48c30

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

doc/api/cli.md

+16
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,21 @@ Load an OpenSSL configuration file on startup. Among other uses, this can be
635635
used to enable FIPS-compliant crypto if Node.js is built
636636
against FIPS-enabled OpenSSL.
637637

638+
### `--openssl-shared-config`
639+
640+
<!-- YAML
641+
added: REPLACEME
642+
-->
643+
644+
Enable OpenSSL default configuration section, `openssl_conf` to be read from
645+
the OpenSSL configuration file. The default configuration file is named
646+
`openssl.cnf` but this can be changed using the environment variable
647+
`OPENSSL_CONF`, or by using the command line option `--openssl-config`.
648+
The location of the default OpenSSL configuration file depends on how OpenSSL
649+
is being linked to Node.js. Sharing the OpenSSL configuration may have unwanted
650+
implications and it is recommended to use a configuration section specific to
651+
Node.js which is `nodejs_conf` and is default when this option is not used.
652+
638653
### `--pending-deprecation`
639654
<!-- YAML
640655
added: v8.0.0
@@ -1372,6 +1387,7 @@ Node.js options that are allowed are:
13721387
* `--no-warnings`
13731388
* `--node-memory-debug`
13741389
* `--openssl-config`
1390+
* `--openssl-shared-config`
13751391
* `--pending-deprecation`
13761392
* `--policy-integrity`
13771393
* `--preserve-symlinks-main`

src/node.cc

+6
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,12 @@ InitializationResult InitializeOncePerProcess(int argc, char** argv) {
10531053
const char* conf_file = nullptr;
10541054
// Use OPENSSL_CONF environment variable is set.
10551055
std::string env_openssl_conf;
1056+
// To allow for using the previous default where the 'openssl_conf' appname
1057+
// was used, the command line option 'openssl-shared-config' can be used to
1058+
// force the old behavior.
1059+
if (per_process::cli_options->openssl_shared_config) {
1060+
conf_section_name = "openssl_conf";
1061+
}
10561062
credentials::SafeGetenv("OPENSSL_CONF", &env_openssl_conf);
10571063
if (!env_openssl_conf.empty()) {
10581064
conf_file = env_openssl_conf.c_str();

src/node_options.cc

+4
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,10 @@ PerProcessOptionsParser::PerProcessOptionsParser(
779779
"force FIPS crypto (cannot be disabled)",
780780
&PerProcessOptions::force_fips_crypto,
781781
kAllowedInEnvironment);
782+
AddOption("--openssl-shared-config",
783+
"enable OpenSSL shared configuration",
784+
&PerProcessOptions::openssl_shared_config,
785+
kAllowedInEnvironment);
782786
#endif
783787
AddOption("--use-largepages",
784788
"Map the Node.js static code to large pages. Options are "

src/node_options.h

+1
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ class PerProcessOptions : public Options {
238238
// or are used once during process initialization.
239239
#if HAVE_OPENSSL
240240
std::string openssl_config;
241+
bool openssl_shared_config = false;
241242
std::string tls_cipher_list = DEFAULT_CIPHER_LIST_CORE;
242243
#ifdef NODE_OPENSSL_CERT_STORE
243244
bool ssl_openssl_cert_store = true;

test/parallel/test-process-env-allowed-flags-are-documented.js

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const conditionalOpts = [
4747
filter: (opt) => {
4848
return [
4949
'--openssl-config',
50+
'--openssl-shared-config',
5051
'--tls-cipher-list',
5152
'--use-bundled-ca',
5253
'--use-openssl-ca',

0 commit comments

Comments
 (0)