src: add --openssl-legacy-provider option · nodejs/node@1d2f37d · GitHub
Skip to content

Commit 1d2f37d

Browse files
committed
src: add --openssl-legacy-provider option
This commit adds an option to Node.js named --openssl-legacy-provider and if specified will load OpenSSL 3.0 Legacy provider. $ ./node --help ... --openssl-legacy-provider enable OpenSSL 3.0 legacy provider Example usage: $ ./node --openssl-legacy-provider -p 'crypto.createHash("md4")' Hash { _options: undefined, [Symbol(kHandle)]: Hash {}, [Symbol(kState)]: { [Symbol(kFinalized)]: false } } Co-authored-by: Richard Lau <rlau@redhat.com> Refs: #40455 PR-URL: #40478 Refs: #40455 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent d434c53 commit 1d2f37d

5 files changed

Lines changed: 42 additions & 0 deletions

File tree

doc/api/cli.md

Lines changed: 10 additions & 0 deletions

src/crypto/crypto_util.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ void InitCryptoOnce() {
136136
}
137137
#endif
138138

139+
#if OPENSSL_VERSION_MAJOR >= 3
140+
// --openssl-legacy-provider
141+
if (per_process::cli_options->openssl_legacy_provider) {
142+
OSSL_PROVIDER* legacy_provider = OSSL_PROVIDER_load(nullptr, "legacy");
143+
if (legacy_provider == nullptr) {
144+
fprintf(stderr, "Unable to load legacy provider.\n");
145+
}
146+
}
147+
#endif
148+
139149
OPENSSL_init_ssl(0, settings);
140150
OPENSSL_INIT_free(settings);
141151
settings = nullptr;

src/node_options.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#include "env-inl.h"
55
#include "node_binding.h"
66
#include "node_internals.h"
7+
#if HAVE_OPENSSL
8+
#include "openssl/opensslv.h"
9+
#endif
710

811
#include <errno.h>
912
#include <sstream>
@@ -814,6 +817,13 @@ PerProcessOptionsParser::PerProcessOptionsParser(
814817
&PerProcessOptions::secure_heap_min,
815818
kAllowedInEnvironment);
816819
#endif
820+
#if OPENSSL_VERSION_MAJOR >= 3
821+
AddOption("--openssl-legacy-provider",
822+
"enable OpenSSL 3.0 legacy provider",
823+
&PerProcessOptions::openssl_legacy_provider,
824+
kAllowedInEnvironment);
825+
826+
#endif // OPENSSL_VERSION_MAJOR
817827
AddOption("--use-largepages",
818828
"Map the Node.js static code to large pages. Options are "
819829
"'off' (the default value, meaning do not map), "

src/node_options.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
#include "node_mutex.h"
1212
#include "util.h"
1313

14+
#if HAVE_OPENSSL
15+
#include "openssl/opensslv.h"
16+
#endif
17+
1418
namespace node {
1519

1620
class HostPort {
@@ -252,6 +256,9 @@ class PerProcessOptions : public Options {
252256
bool enable_fips_crypto = false;
253257
bool force_fips_crypto = false;
254258
#endif
259+
#if OPENSSL_VERSION_MAJOR >= 3
260+
bool openssl_legacy_provider = false;
261+
#endif
255262

256263
// Per-process because reports can be triggered outside a known V8 context.
257264
bool report_on_fatalerror = false;

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

Lines changed: 5 additions & 0 deletions

0 commit comments

Comments
 (0)