Skip to content

Commit a2cd8aa

Browse files
committed
crypto,https,tls: end OpenSSL engine support
OpenSSL removed support for engines in version 4. Remove the Node.js APIs, constants, native bindings, and implementation that depend on ENGINE. Keep recognizing the former TLS and HTTPS engine options so their use fails explicitly instead of appearing to work while being ignored. Move DEP0183 directly from Documentation-only to End-of-Life after reverting its unreleased Runtime deprecation. Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: Codex PR-URL: #64777 Fixes: #56733 Refs: #64211 Refs: #63966 Refs: #53329 Refs: #48950 Refs: #45465 Refs: #42827 Refs: #47076 Refs: #62862 Refs: #38512 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
1 parent b61e682 commit a2cd8aa

41 files changed

Lines changed: 174 additions & 1290 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎deps/ncrypto/engine.cc‎

Lines changed: 0 additions & 105 deletions
This file was deleted.

‎deps/ncrypto/ncrypto.gyp‎

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
'ncrypto.cc',
66
'ncrypto.h',
77
],
8-
'ncrypto_engine_sources': [
9-
'engine.cc',
10-
'ncrypto.h',
11-
],
128
# OpenSSL may be configured with --api below 3.0. Keep 3.0 deprecation
139
# checks where supported without exceeding its configured API level.
1410
'ncrypto_openssl3_api_compat':
@@ -17,11 +13,6 @@
1713
'OPENSSL_API_COMPAT=<(ncrypto_openssl3_api_compat)',
1814
'OPENSSL_NO_DEPRECATED',
1915
],
20-
'ncrypto_engine_defines': [
21-
'OPENSSL_API_COMPAT=<(ncrypto_openssl3_api_compat)',
22-
'OPENSSL_SUPPRESS_DEPRECATED',
23-
'NCRYPTO_ENGINE_COMPAT=1',
24-
],
2516
},
2617
'targets': [
2718
{
@@ -46,9 +37,6 @@
4637
'conditions': [
4738
['openssl_is_boringssl=="false"', {
4839
'defines': [ '<@(ncrypto_strict_defines)' ],
49-
'dependencies': [
50-
'ncrypto_engine',
51-
],
5240
}],
5341
['node_shared_openssl=="false"', {
5442
'dependencies': [
@@ -58,27 +46,4 @@
5846
]
5947
},
6048
],
61-
'conditions': [
62-
['openssl_is_boringssl=="false"', {
63-
'targets': [
64-
{
65-
'target_name': 'ncrypto_engine',
66-
'type': 'static_library',
67-
'include_dirs': ['.'],
68-
'defines': [
69-
'NCRYPTO_BSSL_LIBDECREPIT_MISSING=<(ncrypto_bssl_libdecrepit_missing)',
70-
'<@(ncrypto_engine_defines)',
71-
],
72-
'sources': [ '<@(ncrypto_engine_sources)' ],
73-
'conditions': [
74-
['node_shared_openssl=="false"', {
75-
'dependencies': [
76-
'../openssl/openssl.gyp:openssl'
77-
]
78-
}],
79-
]
80-
},
81-
],
82-
}],
83-
],
8449
}

‎deps/ncrypto/ncrypto.h‎

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@
2323
#include <string_view>
2424
#include <unordered_map>
2525
#include <vector>
26-
#if defined(NCRYPTO_ENGINE_COMPAT) && NCRYPTO_ENGINE_COMPAT && \
27-
!defined(OPENSSL_NO_ENGINE)
28-
#include <openssl/engine.h>
29-
#endif // NCRYPTO_ENGINE_COMPAT && !OPENSSL_NO_ENGINE
30-
3126
#ifndef OPENSSL_VERSION_PREREQ
3227
#define OPENSSL_VERSION_PREREQ(maj, min) \
3328
(OPENSSL_VERSION_NUMBER >= (((maj) << 28) | ((min) << 20)))
@@ -2109,44 +2104,6 @@ class MacCache final {
21092104
};
21102105
#endif
21112106

2112-
#ifndef OPENSSL_NO_ENGINE
2113-
class EnginePointer final {
2114-
public:
2115-
EnginePointer() = default;
2116-
2117-
explicit EnginePointer(void* engine_, bool finish_on_exit = false);
2118-
EnginePointer(EnginePointer&& other) noexcept;
2119-
EnginePointer& operator=(EnginePointer&& other) noexcept;
2120-
NCRYPTO_DISALLOW_COPY(EnginePointer)
2121-
~EnginePointer();
2122-
2123-
inline operator bool() const { return engine != nullptr; }
2124-
inline void setFinishOnExit() { finish_on_exit = true; }
2125-
2126-
void reset(void* engine_ = nullptr, bool finish_on_exit_ = false);
2127-
2128-
bool setAsDefault(uint32_t flags, CryptoErrorList* errors = nullptr);
2129-
bool init(bool finish_on_exit = false);
2130-
EVPKeyPointer loadPrivateKey(const char* key_name);
2131-
bool setClientCertEngine(SSL_CTX* ctx);
2132-
2133-
void* release();
2134-
2135-
// Retrieve an OpenSSL Engine instance by name. If the name does not
2136-
// identify a valid named engine, the returned EnginePointer will be
2137-
// empty.
2138-
static EnginePointer getEngineByName(const char* name,
2139-
CryptoErrorList* errors = nullptr);
2140-
2141-
// Call once when initializing OpenSSL at startup for the process.
2142-
static void initEnginesOnce();
2143-
2144-
private:
2145-
void* engine = nullptr;
2146-
bool finish_on_exit = false;
2147-
};
2148-
#endif // !OPENSSL_NO_ENGINE
2149-
21502107
// ============================================================================
21512108
// FIPS
21522109
bool isFipsEnabled();

‎deps/ncrypto/unofficial.gni‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ template("ncrypto_gn_build") {
2626
source_set(target_name) {
2727
forward_variables_from(invoker, "*")
2828
public_configs = [ ":ncrypto_config" ]
29-
defines = [
30-
"NCRYPTO_ENGINE_COMPAT=1",
31-
"OPENSSL_SUPPRESS_DEPRECATED",
32-
]
33-
sources = gypi_values.ncrypto_sources + gypi_values.ncrypto_engine_sources
29+
sources = gypi_values.ncrypto_sources
3430
deps = [ "$node_openssl_path" ]
3531
}
3632
}

‎doc/api/crypto.md‎

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -6601,42 +6601,6 @@ added: v15.6.0
66016601
* `utilization` {number} The calculated ratio of `used` to `total`
66026602
allocated bytes.
66036603

6604-
### `crypto.setEngine(engine[, flags])`
6605-
6606-
<!-- YAML
6607-
added: v0.11.11
6608-
changes:
6609-
- version:
6610-
- v22.4.0
6611-
- v20.16.0
6612-
pr-url: https://github.com/nodejs/node/pull/53329
6613-
description: Custom engine support in OpenSSL 3 is deprecated.
6614-
-->
6615-
6616-
* `engine` {string}
6617-
* `flags` {crypto.constants} **Default:** `crypto.constants.ENGINE_METHOD_ALL`
6618-
6619-
Load and set the `engine` for some or all OpenSSL functions (selected by flags).
6620-
Support for custom engines in OpenSSL is deprecated from OpenSSL 3.
6621-
6622-
`engine` could be either an id or a path to the engine's shared library.
6623-
6624-
The optional `flags` argument uses `ENGINE_METHOD_ALL` by default. The `flags`
6625-
is a bit field taking one of or a mix of the following flags (defined in
6626-
`crypto.constants`):
6627-
6628-
* `crypto.constants.ENGINE_METHOD_RSA`
6629-
* `crypto.constants.ENGINE_METHOD_DSA`
6630-
* `crypto.constants.ENGINE_METHOD_DH`
6631-
* `crypto.constants.ENGINE_METHOD_RAND`
6632-
* `crypto.constants.ENGINE_METHOD_EC`
6633-
* `crypto.constants.ENGINE_METHOD_CIPHERS`
6634-
* `crypto.constants.ENGINE_METHOD_DIGESTS`
6635-
* `crypto.constants.ENGINE_METHOD_PKEY_METHS`
6636-
* `crypto.constants.ENGINE_METHOD_PKEY_ASN1_METHS`
6637-
* `crypto.constants.ENGINE_METHOD_ALL`
6638-
* `crypto.constants.ENGINE_METHOD_NONE`
6639-
66406604
### `crypto.setFips(bool)`
66416605

66426606
<!-- YAML
@@ -7463,59 +7427,6 @@ See the [list of SSL OP Flags][] for details.
74637427
</tr>
74647428
</table>
74657429

7466-
### OpenSSL engine constants
7467-
7468-
<table>
7469-
<tr>
7470-
<th>Constant</th>
7471-
<th>Description</th>
7472-
</tr>
7473-
<tr>
7474-
<td><code>ENGINE_METHOD_RSA</code></td>
7475-
<td>Limit engine usage to RSA</td>
7476-
</tr>
7477-
<tr>
7478-
<td><code>ENGINE_METHOD_DSA</code></td>
7479-
<td>Limit engine usage to DSA</td>
7480-
</tr>
7481-
<tr>
7482-
<td><code>ENGINE_METHOD_DH</code></td>
7483-
<td>Limit engine usage to DH</td>
7484-
</tr>
7485-
<tr>
7486-
<td><code>ENGINE_METHOD_RAND</code></td>
7487-
<td>Limit engine usage to RAND</td>
7488-
</tr>
7489-
<tr>
7490-
<td><code>ENGINE_METHOD_EC</code></td>
7491-
<td>Limit engine usage to EC</td>
7492-
</tr>
7493-
<tr>
7494-
<td><code>ENGINE_METHOD_CIPHERS</code></td>
7495-
<td>Limit engine usage to CIPHERS</td>
7496-
</tr>
7497-
<tr>
7498-
<td><code>ENGINE_METHOD_DIGESTS</code></td>
7499-
<td>Limit engine usage to DIGESTS</td>
7500-
</tr>
7501-
<tr>
7502-
<td><code>ENGINE_METHOD_PKEY_METHS</code></td>
7503-
<td>Limit engine usage to PKEY_METHS</td>
7504-
</tr>
7505-
<tr>
7506-
<td><code>ENGINE_METHOD_PKEY_ASN1_METHS</code></td>
7507-
<td>Limit engine usage to PKEY_ASN1_METHS</td>
7508-
</tr>
7509-
<tr>
7510-
<td><code>ENGINE_METHOD_ALL</code></td>
7511-
<td></td>
7512-
</tr>
7513-
<tr>
7514-
<td><code>ENGINE_METHOD_NONE</code></td>
7515-
<td></td>
7516-
</tr>
7517-
</table>
7518-
75197430
### Other OpenSSL constants
75207431

75217432
<table>

‎doc/api/deprecations.md‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4111,20 +4111,25 @@ that are shorter than the default authentication tag length (i.e., shorter than
41114111

41124112
<!-- YAML
41134113
changes:
4114+
- version: REPLACEME
4115+
pr-url: https://github.com/nodejs/node/pull/64777
4116+
description: End-of-Life.
41144117
- version:
41154118
- v22.4.0
41164119
- v20.16.0
41174120
pr-url: https://github.com/nodejs/node/pull/53329
41184121
description: Documentation-only deprecation.
41194122
-->
41204123

4121-
Type: Documentation-only
4124+
Type: End-of-Life
41224125

4123-
OpenSSL 3 has deprecated support for custom engines with a recommendation to
4124-
switch to its new provider model. The `clientCertEngine` option for
4125-
`https.request()`, [`tls.createSecureContext()`][], and [`tls.createServer()`][];
4126-
the `privateKeyEngine` and `privateKeyIdentifier` for [`tls.createSecureContext()`][];
4127-
and [`crypto.setEngine()`][] all depend on this functionality from OpenSSL.
4126+
The `crypto.setEngine()` API and the `crypto.constants.ENGINE_METHOD_*`
4127+
constants have been removed. The `clientCertEngine` option for
4128+
[`https.request()`][], [`tls.createSecureContext()`][], and
4129+
[`tls.createServer()`][] and the `privateKeyEngine` and `privateKeyIdentifier`
4130+
options for [`tls.createSecureContext()`][] now throw
4131+
`ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED` when used. There is no direct
4132+
replacement API in Node.js. OpenSSL's provider model replaces engines upstream.
41284133

41294134
### DEP0184: Instantiating `node:zlib` classes without `new`
41304135

@@ -4887,7 +4892,6 @@ Type: Documentation-only
48874892
[`crypto.pbkdf2()`]: crypto.md#cryptopbkdf2password-salt-iterations-keylen-digest-callback
48884893
[`crypto.randomBytes()`]: crypto.md#cryptorandombytessize-callback
48894894
[`crypto.scrypt()`]: crypto.md#cryptoscryptpassword-salt-keylen-options-callback
4890-
[`crypto.setEngine()`]: crypto.md#cryptosetengineengine-flags
48914895
[`decipher.final()`]: crypto.md#decipherfinaloutputencoding
48924896
[`decipher.setAuthTag()`]: crypto.md#deciphersetauthtagbuffer-encoding
48934897
[`dirent.parentPath`]: fs.md#direntparentpath

0 commit comments

Comments
 (0)