Skip to content

Commit 9ea9797

Browse files
danbevtargos
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: #43892 Refs: #40366 Refs: nodejs/nodejs.org#4713 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 222a6e9 commit 9ea9797

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

doc/api/cli.md

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

752+
### `--openssl-shared-config`
753+
754+
<!-- YAML
755+
added: REPLACEME
756+
-->
757+
758+
Enable OpenSSL default configuration section, `openssl_conf` to be read from
759+
the OpenSSL configuration file. The default configuration file is named
760+
`openssl.cnf` but this can be changed using the environment variable
761+
`OPENSSL_CONF`, or by using the command line option `--openssl-config`.
762+
The location of the default OpenSSL configuration file depends on how OpenSSL
763+
is being linked to Node.js. Sharing the OpenSSL configuration may have unwanted
764+
implications and it is recommended to use a configuration section specific to
765+
Node.js which is `nodejs_conf` and is default when this option is not used.
766+
752767
### `--openssl-legacy-provider`
753768

754769
<!-- YAML
@@ -1620,6 +1635,7 @@ Node.js options that are allowed are:
16201635
* `--node-memory-debug`
16211636
* `--openssl-config`
16221637
* `--openssl-legacy-provider`
1638+
* `--openssl-shared-config`
16231639
* `--pending-deprecation`
16241640
* `--policy-integrity`
16251641
* `--preserve-symlinks-main`

src/node.cc

+6
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

+4-1
Original file line numberDiff line numberDiff line change
@@ -824,13 +824,16 @@ PerProcessOptionsParser::PerProcessOptionsParser(
824824
"minimum allocation size from the OpenSSL secure heap",
825825
&PerProcessOptions::secure_heap_min,
826826
kAllowedInEnvironment);
827+
AddOption("--openssl-shared-config",
828+
"enable OpenSSL shared configuration",
829+
&PerProcessOptions::openssl_shared_config,
830+
kAllowedInEnvironment);
827831
#endif // HAVE_OPENSSL
828832
#if OPENSSL_VERSION_MAJOR >= 3
829833
AddOption("--openssl-legacy-provider",
830834
"enable OpenSSL 3.0 legacy provider",
831835
&PerProcessOptions::openssl_legacy_provider,
832836
kAllowedInEnvironment);
833-
834837
#endif // OPENSSL_VERSION_MAJOR
835838
AddOption("--use-largepages",
836839
"Map the Node.js static code to large pages. Options are "

src/node_options.h

+1
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ class PerProcessOptions : public Options {
247247
std::string tls_cipher_list = DEFAULT_CIPHER_LIST_CORE;
248248
int64_t secure_heap = 0;
249249
int64_t secure_heap_min = 2;
250+
bool openssl_shared_config = false;
250251
#ifdef NODE_OPENSSL_CERT_STORE
251252
bool ssl_openssl_cert_store = true;
252253
#else

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

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const conditionalOpts = [
5555
return [
5656
'--openssl-config',
5757
common.hasOpenSSL3 ? '--openssl-legacy-provider' : '',
58+
'--openssl-shared-config',
5859
'--tls-cipher-list',
5960
'--use-bundled-ca',
6061
'--use-openssl-ca',

0 commit comments

Comments
 (0)