Skip to content

Commit 122c377

Browse files
committedMay 31, 2022
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: nodejs#43124 Refs: nodejs#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]>
1 parent f5a5df4 commit 122c377

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
@@ -783,6 +783,21 @@ Load an OpenSSL configuration file on startup. Among other uses, this can be
783783
used to enable FIPS-compliant crypto if Node.js is built
784784
against FIPS-enabled OpenSSL.
785785

786+
### `--openssl-shared-config`
787+
788+
<!-- YAML
789+
added: REPLACEME
790+
-->
791+
792+
Enable OpenSSL default configuration section, `openssl_conf` to be read from
793+
the OpenSSL configuration file. The default configuration file is named
794+
`openssl.cnf` but this can be changed using the environment variable
795+
`OPENSSL_CONF`, or by using the command line option `--openssl-config`.
796+
The location of the default OpenSSL configuration file depends on how OpenSSL
797+
is being linked to Node.js. Sharing the OpenSSL configuration may have unwanted
798+
implications and it is recommended to use a configuration section specific to
799+
Node.js which is `nodejs_conf` and is default when this option is not used.
800+
786801
### `--openssl-legacy-provider`
787802

788803
<!-- YAML
@@ -1675,6 +1690,7 @@ Node.js options that are allowed are:
16751690
* `--node-memory-debug`
16761691
* `--openssl-config`
16771692
* `--openssl-legacy-provider`
1693+
* `--openssl-shared-config`
16781694
* `--pending-deprecation`
16791695
* `--policy-integrity`
16801696
* `--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
@@ -869,6 +869,10 @@ PerProcessOptionsParser::PerProcessOptionsParser(
869869
"enable OpenSSL 3.0 legacy provider",
870870
&PerProcessOptions::openssl_legacy_provider,
871871
kAllowedInEnvironment);
872+
AddOption("--openssl-shared-config",
873+
"enable OpenSSL shared configuration",
874+
&PerProcessOptions::openssl_shared_config,
875+
kAllowedInEnvironment);
872876

873877
#endif // OPENSSL_VERSION_MAJOR
874878
AddOption("--use-largepages",

‎src/node_options.h

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

271272
// 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)