Skip to content

Commit ecdead2

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 <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com>
1 parent d2cd443 commit ecdead2

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

doc/api/cli.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,21 @@ Load an OpenSSL configuration file on startup. Among other uses, this can be
732732
used to enable FIPS-compliant crypto if Node.js is built
733733
against FIPS-enabled OpenSSL.
734734

735+
### `--openssl-shared-config`
736+
737+
<!-- YAML
738+
added: REPLACEME
739+
-->
740+
741+
Enable OpenSSL default configuration section, `openssl_conf` to be read from
742+
the OpenSSL configuration file. The default configuration file is named
743+
`openssl.cnf` but this can be changed using the environment variable
744+
`OPENSSL_CONF`, or by using the command line option `--openssl-config`.
745+
The location of the default OpenSSL configuration file depends on how OpenSSL
746+
is being linked to Node.js. Sharing the OpenSSL configuration may have unwanted
747+
implications and it is recommended to use a configuration section specific to
748+
Node.js which is `nodejs_conf` and is default when this option is not used.
749+
735750
### `--pending-deprecation`
736751

737752
<!-- YAML
@@ -1592,6 +1607,7 @@ Node.js options that are allowed are:
15921607
* `--no-warnings`
15931608
* `--node-memory-debug`
15941609
* `--openssl-config`
1610+
* `--openssl-shared-config`
15951611
* `--pending-deprecation`
15961612
* `--policy-integrity`
15971613
* `--preserve-symlinks-main`

src/node.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,12 @@ InitializationResult InitializeOncePerProcess(
10961096
// instead only the section that matches the value of conf_section_name
10971097
// will be read from the default configuration file.
10981098
const char* conf_file = nullptr;
1099+
// To allow for using the previous default where the 'openssl_conf' appname
1100+
// was used, the command line option 'openssl-shared-config' can be used to
1101+
// force the old behavior.
1102+
if (per_process::cli_options->openssl_shared_config) {
1103+
conf_section_name = "openssl_conf";
1104+
}
10991105
// Use OPENSSL_CONF environment variable is set.
11001106
std::string env_openssl_conf;
11011107
credentials::SafeGetenv("OPENSSL_CONF", &env_openssl_conf);

src/node_options.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,13 +821,16 @@ PerProcessOptionsParser::PerProcessOptionsParser(
821821
"minimum allocation size from the OpenSSL secure heap",
822822
&PerProcessOptions::secure_heap_min,
823823
kAllowedInEnvironment);
824+
AddOption("--openssl-shared-config",
825+
"enable OpenSSL shared configuration",
826+
&PerProcessOptions::openssl_shared_config,
827+
kAllowedInEnvironment);
824828
#endif // HAVE_OPENSSL
825829
#if OPENSSL_VERSION_MAJOR >= 3
826830
AddOption("--openssl-legacy-provider",
827831
"enable OpenSSL 3.0 legacy provider",
828832
&PerProcessOptions::openssl_legacy_provider,
829833
kAllowedInEnvironment);
830-
831834
#endif // OPENSSL_VERSION_MAJOR
832835
AddOption("--use-largepages",
833836
"Map the Node.js static code to large pages. Options are "

src/node_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ class PerProcessOptions : public Options {
240240
// or are used once during process initialization.
241241
#if HAVE_OPENSSL
242242
std::string openssl_config;
243+
bool openssl_shared_config = false;
243244
std::string tls_cipher_list = DEFAULT_CIPHER_LIST_CORE;
244245
int64_t secure_heap = 0;
245246
int64_t secure_heap_min = 2;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const conditionalOpts = [
5050
filter: (opt) => {
5151
return [
5252
'--openssl-config',
53+
'--openssl-shared-config',
5354
'--tls-cipher-list',
5455
'--use-bundled-ca',
5556
'--use-openssl-ca',

0 commit comments

Comments
 (0)