Skip to content

Commit 9578158

Browse files
danbevBethGriggs
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 Backport-PR-URL: #43539 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 3f0c3e1 commit 9578158

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

doc/api/cli.md

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

774+
### `--openssl-shared-config`
775+
776+
<!-- YAML
777+
added: REPLACEME
778+
-->
779+
780+
Enable OpenSSL default configuration section, `openssl_conf` to be read from
781+
the OpenSSL configuration file. The default configuration file is named
782+
`openssl.cnf` but this can be changed using the environment variable
783+
`OPENSSL_CONF`, or by using the command line option `--openssl-config`.
784+
The location of the default OpenSSL configuration file depends on how OpenSSL
785+
is being linked to Node.js. Sharing the OpenSSL configuration may have unwanted
786+
implications and it is recommended to use a configuration section specific to
787+
Node.js which is `nodejs_conf` and is default when this option is not used.
788+
774789
### `--openssl-legacy-provider`
775790

776791
<!-- YAML
@@ -1662,6 +1677,7 @@ Node.js options that are allowed are:
16621677
* `--node-memory-debug`
16631678
* `--openssl-config`
16641679
* `--openssl-legacy-provider`
1680+
* `--openssl-shared-config`
16651681
* `--pending-deprecation`
16661682
* `--policy-integrity`
16671683
* `--preserve-symlinks-main`

src/node.cc

+6-1
Original file line numberDiff line numberDiff line change
@@ -1092,8 +1092,13 @@ InitializationResult InitializeOncePerProcess(
10921092
// to be loaded, but the default section in that file will not be used,
10931093
// instead only the section that matches the value of conf_section_name
10941094
// will be read from the default configuration file.
1095-
// fprintf(stderr, "appanme: %s\n", conf_section_name);
10961095
const char* conf_file = nullptr;
1096+
// To allow for using the previous default where the 'openssl_conf' appname
1097+
// was used, the command line option 'openssl-shared-config' can be used to
1098+
// force the old behavior.
1099+
if (per_process::cli_options->openssl_shared_config) {
1100+
conf_section_name = "openssl_conf";
1101+
}
10971102
// Use OPENSSL_CONF environment variable is set.
10981103
std::string env_openssl_conf;
10991104
credentials::SafeGetenv("OPENSSL_CONF", &env_openssl_conf);

src/node_options.cc

+4
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,10 @@ PerProcessOptionsParser::PerProcessOptionsParser(
860860
"enable OpenSSL 3.0 legacy provider",
861861
&PerProcessOptions::openssl_legacy_provider,
862862
kAllowedInEnvironment);
863+
AddOption("--openssl-shared-config",
864+
"enable OpenSSL shared configuration",
865+
&PerProcessOptions::openssl_shared_config,
866+
kAllowedInEnvironment);
863867

864868
#endif // OPENSSL_VERSION_MAJOR
865869
AddOption("--use-largepages",

src/node_options.h

+1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ class PerProcessOptions : public Options {
265265
#endif
266266
#if OPENSSL_VERSION_MAJOR >= 3
267267
bool openssl_legacy_provider = false;
268+
bool openssl_shared_config = false;
268269
#endif
269270

270271
// Per-process because reports can be triggered outside a known V8 context.

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

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ for (const line of [...nodeOptionsLines, ...v8OptionsLines]) {
4545

4646
if (!common.hasOpenSSL3) {
4747
documented.delete('--openssl-legacy-provider');
48+
documented.delete('--openssl-shared-config');
4849
}
4950

5051
// Filter out options that are conditionally present.
@@ -55,6 +56,7 @@ const conditionalOpts = [
5556
return [
5657
'--openssl-config',
5758
common.hasOpenSSL3 ? '--openssl-legacy-provider' : '',
59+
common.hasOpenSSL3 ? '--openssl-shared-config' : '',
5860
'--tls-cipher-list',
5961
'--use-bundled-ca',
6062
'--use-openssl-ca',

0 commit comments

Comments
 (0)