summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrej Valek <andrej.valek@siemens.com>2022-03-05 14:16:25 +0100
committerKhem Raj <raj.khem@gmail.com>2022-03-09 07:37:42 -0800
commit93ec055d832357589066dc7a51c7a7680e96c1f9 (patch)
tree0b2c936f01bf490f35d06409594a6c0c3bacf57f
parent02422135f345d73b10fdb7057b1daa1401c346f0 (diff)
downloadmeta-openembedded-93ec055d832357589066dc7a51c7a7680e96c1f9.tar.gz
nodejs: add option to use openssl legacy providers again
Current nodejs version v16 does not fully support new OpenSSL, so add option to use legacy provider. | opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], | library: 'digital envelope routines', | reason: 'unsupported', | code: 'ERR_OSSL_EVP_UNSUPPORTED' It was blindly removed by upgrade to 16.14.0 version Signed-off-by: Andrej Valek <andrej.valek@siemens.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r--meta-oe/recipes-devtools/nodejs/nodejs/0005-add-openssl-legacy-provider-option.patch151
-rw-r--r--meta-oe/recipes-devtools/nodejs/nodejs_16.14.0.bb1
2 files changed, 152 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/nodejs/nodejs/0005-add-openssl-legacy-provider-option.patch b/meta-oe/recipes-devtools/nodejs/nodejs/0005-add-openssl-legacy-provider-option.patch
new file mode 100644
index 0000000000..4d238c03f4
--- /dev/null
+++ b/meta-oe/recipes-devtools/nodejs/nodejs/0005-add-openssl-legacy-provider-option.patch
@@ -0,0 +1,151 @@
1From 86d1c0cc6a5dcf57e413a1cc1c29203e87cf9a14 Mon Sep 17 00:00:00 2001
2From: Daniel Bevenius <daniel.bevenius@gmail.com>
3Date: Sat, 16 Oct 2021 08:50:16 +0200
4Subject: [PATCH] src: add --openssl-legacy-provider option
5
6This commit adds an option to Node.js named --openssl-legacy-provider
7and if specified will load OpenSSL 3.0 Legacy provider.
8
9$ ./node --help
10...
11--openssl-legacy-provider enable OpenSSL 3.0 legacy provider
12
13Example usage:
14
15$ ./node --openssl-legacy-provider -p 'crypto.createHash("md4")'
16Hash {
17 _options: undefined,
18 [Symbol(kHandle)]: Hash {},
19 [Symbol(kState)]: { [Symbol(kFinalized)]: false }
20}
21
22Co-authored-by: Richard Lau <rlau@redhat.com>
23Signed-off-by: Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
24Upstream-Status: Backport [https://github.com/nodejs/node/issues/40455]
25---
26 doc/api/cli.md | 10 ++++++++++
27 src/crypto/crypto_util.cc | 10 ++++++++++
28 src/node_options.cc | 10 ++++++++++
29 src/node_options.h | 7 +++++++
30 .../test-process-env-allowed-flags-are-documented.js | 5 +++++
31 5 files changed, 42 insertions(+)
32
33diff --git a/doc/api/cli.md b/doc/api/cli.md
34index 74057706bf8d..608b9cdeddf1 100644
35--- a/doc/api/cli.md
36+++ b/doc/api/cli.md
37@@ -687,6 +687,14 @@ Load an OpenSSL configuration file on startup. Among other uses, this can be
38 used to enable FIPS-compliant crypto if Node.js is built
39 against FIPS-enabled OpenSSL.
40
41+### `--openssl-legacy-provider`
42+<!-- YAML
43+added: REPLACEME
44+-->
45+
46+Enable OpenSSL 3.0 legacy provider. For more information please see
47+[providers readme][].
48+
49 ### `--pending-deprecation`
50
51 <!-- YAML
52@@ -1544,6 +1552,7 @@ Node.js options that are allowed are:
53 * `--no-warnings`
54 * `--node-memory-debug`
55 * `--openssl-config`
56+* `--openssl-legacy-provider`
57 * `--pending-deprecation`
58 * `--policy-integrity`
59 * `--preserve-symlinks-main`
60@@ -1933,6 +1942,7 @@ $ node --max-old-space-size=1536 index.js
61 [emit_warning]: process.md#processemitwarningwarning-options
62 [jitless]: https://v8.dev/blog/jitless
63 [libuv threadpool documentation]: https://docs.libuv.org/en/latest/threadpool.html
64+[providers readme]: https://github.com/openssl/openssl/blob/openssl-3.0.0/README-PROVIDERS.md
65 [remote code execution]: https://www.owasp.org/index.php/Code_Injection
66 [security warning]: #warning-binding-inspector-to-a-public-ipport-combination-is-insecure
67 [timezone IDs]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
68diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc
69index 7e0c8ba3eb60..796ea3025e41 100644
70--- a/src/crypto/crypto_util.cc
71+++ b/src/crypto/crypto_util.cc
72@@ -148,6 +148,16 @@ void InitCryptoOnce() {
73 }
74 #endif
75
76+#if OPENSSL_VERSION_MAJOR >= 3
77+ // --openssl-legacy-provider
78+ if (per_process::cli_options->openssl_legacy_provider) {
79+ OSSL_PROVIDER* legacy_provider = OSSL_PROVIDER_load(nullptr, "legacy");
80+ if (legacy_provider == nullptr) {
81+ fprintf(stderr, "Unable to load legacy provider.\n");
82+ }
83+ }
84+#endif
85+
86 OPENSSL_init_ssl(0, settings);
87 OPENSSL_INIT_free(settings);
88 settings = nullptr;
89diff --git a/src/node_options.cc b/src/node_options.cc
90index 00bdc6688a4c..3363860919a9 100644
91--- a/src/node_options.cc
92+++ b/src/node_options.cc
93@@ -4,6 +4,9 @@
94 #include "env-inl.h"
95 #include "node_binding.h"
96 #include "node_internals.h"
97+#if HAVE_OPENSSL
98+#include "openssl/opensslv.h"
99+#endif
100
101 #include <errno.h>
102 #include <sstream>
103diff --git a/src/node_options.h b/src/node_options.h
104index fd772478d04d..1c0e018ab16f 100644
105--- a/src/node_options.h
106+++ b/src/node_options.h
107@@ -11,6 +11,10 @@
108 #include "node_mutex.h"
109 #include "util.h"
110
111+#if HAVE_OPENSSL
112+#include "openssl/opensslv.h"
113+#endif
114+
115 namespace node {
116
117 class HostPort {
118@@ -251,6 +255,9 @@ class PerProcessOptions : public Options {
119 bool enable_fips_crypto = false;
120 bool force_fips_crypto = false;
121 #endif
122+#if OPENSSL_VERSION_MAJOR >= 3
123+ bool openssl_legacy_provider = false;
124+#endif
125
126 // Per-process because reports can be triggered outside a known V8 context.
127 bool report_on_fatalerror = false;
128diff --git a/test/parallel/test-process-env-allowed-flags-are-documented.js b/test/parallel/test-process-env-allowed-flags-are-documented.js
129index 64626b71f019..8a4e35997907 100644
130--- a/test/parallel/test-process-env-allowed-flags-are-documented.js
131+++ b/test/parallel/test-process-env-allowed-flags-are-documented.js
132@@ -43,6 +43,10 @@ for (const line of [...nodeOptionsLines, ...v8OptionsLines]) {
133 }
134 }
135
136+if (!common.hasOpenSSL3) {
137+ documented.delete('--openssl-legacy-provider');
138+}
139+
140 // Filter out options that are conditionally present.
141 const conditionalOpts = [
142 {
143@@ -50,6 +54,7 @@ const conditionalOpts = [
144 filter: (opt) => {
145 return [
146 '--openssl-config',
147+ common.hasOpenSSL3 ? '--openssl-legacy-provider' : '',
148 '--tls-cipher-list',
149 '--use-bundled-ca',
150 '--use-openssl-ca',
151
diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_16.14.0.bb b/meta-oe/recipes-devtools/nodejs/nodejs_16.14.0.bb
index 9514ec499a..7b9644ec8d 100644
--- a/meta-oe/recipes-devtools/nodejs/nodejs_16.14.0.bb
+++ b/meta-oe/recipes-devtools/nodejs/nodejs_16.14.0.bb
@@ -20,6 +20,7 @@ SRC_URI = "http://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz \
20 file://0001-Disable-running-gyp-files-for-bundled-deps.patch \ 20 file://0001-Disable-running-gyp-files-for-bundled-deps.patch \
21 file://0002-Install-both-binaries-and-use-libdir.patch \ 21 file://0002-Install-both-binaries-and-use-libdir.patch \
22 file://0004-v8-don-t-override-ARM-CFLAGS.patch \ 22 file://0004-v8-don-t-override-ARM-CFLAGS.patch \
23 file://0005-add-openssl-legacy-provider-option.patch \
23 file://big-endian.patch \ 24 file://big-endian.patch \
24 file://mips-less-memory.patch \ 25 file://mips-less-memory.patch \
25 file://system-c-ares.patch \ 26 file://system-c-ares.patch \