Skip to content

Commit da51692

Browse files
committed
crypto,https,tls: runtime-deprecate OpenSSL engine-based APIs (DEP0183)
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #63966 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
1 parent e52ec44 commit da51692

12 files changed

Lines changed: 95 additions & 5 deletions

File tree

doc/api/crypto.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6086,18 +6086,24 @@ added: v15.6.0
60866086
<!-- YAML
60876087
added: v0.11.11
60886088
changes:
6089+
- version: REPLACEME
6090+
pr-url: https://github.com/nodejs/node/pull/63966
6091+
description: Runtime deprecation.
60896092
- version:
60906093
- v22.4.0
60916094
- v20.16.0
60926095
pr-url: https://github.com/nodejs/node/pull/53329
60936096
description: Custom engine support in OpenSSL 3 is deprecated.
60946097
-->
60956098

6099+
> Stability: 0 - Deprecated
6100+
60966101
* `engine` {string}
60976102
* `flags` {crypto.constants} **Default:** `crypto.constants.ENGINE_METHOD_ALL`
60986103

60996104
Load and set the `engine` for some or all OpenSSL functions (selected by flags).
6100-
Support for custom engines in OpenSSL is deprecated from OpenSSL 3.
6105+
Use of this API is deprecated because custom engine support has been deprecated
6106+
since OpenSSL 3.
61016107

61026108
`engine` could be either an id or a path to the engine's shared library.
61036109

doc/api/deprecations.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4058,14 +4058,17 @@ that are shorter than the default authentication tag length (i.e., shorter than
40584058

40594059
<!-- YAML
40604060
changes:
4061+
- version: REPLACEME
4062+
pr-url: https://github.com/nodejs/node/pull/63966
4063+
description: Runtime deprecation.
40614064
- version:
40624065
- v22.4.0
40634066
- v20.16.0
40644067
pr-url: https://github.com/nodejs/node/pull/53329
40654068
description: Documentation-only deprecation.
40664069
-->
40674070

4068-
Type: Documentation-only
4071+
Type: Runtime
40694072

40704073
OpenSSL 3 has deprecated support for custom engines with a recommendation to
40714074
switch to its new provider model. The `clientCertEngine` option for

doc/api/https.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ a `timeout` of 5 seconds.
423423
<!-- YAML
424424
added: v0.3.6
425425
changes:
426+
- version: REPLACEME
427+
pr-url: https://github.com/nodejs/node/pull/63966
428+
description: The `clientCertEngine` option is runtime deprecated.
426429
- version:
427430
- v22.4.0
428431
- v20.16.0

doc/api/tls.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,6 +1895,10 @@ argument.
18951895
<!-- YAML
18961896
added: v0.11.13
18971897
changes:
1898+
- version: REPLACEME
1899+
pr-url: https://github.com/nodejs/node/pull/63966
1900+
description: The `clientCertEngine`, `privateKeyEngine` and
1901+
`privateKeyIdentifier` options are runtime deprecated.
18981902
- version: REPLACEME
18991903
pr-url: https://github.com/nodejs/node/pull/62217
19001904
description: The `certificateCompression` option has been added.
@@ -2113,6 +2117,9 @@ permissible, use 2048 bits or larger for stronger security.
21132117
<!-- YAML
21142118
added: v0.3.2
21152119
changes:
2120+
- version: REPLACEME
2121+
pr-url: https://github.com/nodejs/node/pull/63966
2122+
description: The `clientCertEngine` option is runtime deprecated.
21162123
- version:
21172124
- v22.4.0
21182125
- v20.16.0

lib/internal/crypto/util.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ const {
7878
cachedResult,
7979
emitExperimentalWarning,
8080
filterDuplicateStrings,
81+
getDeprecationWarningEmitter,
8182
lazyDOMException,
8283
setOwnProperty,
8384
} = require('internal/util');
@@ -131,6 +132,11 @@ const getCiphers = cachedResult(() => filterDuplicateStrings(_getCiphers()));
131132
const getHashes = cachedResult(() => filterDuplicateStrings(_getHashes()));
132133
const getCurves = cachedResult(() => filterDuplicateStrings(_getCurves()));
133134

135+
const emitOpenSSLEngineDeprecation = getDeprecationWarningEmitter(
136+
'DEP0183',
137+
'OpenSSL engine-based APIs are deprecated.',
138+
);
139+
134140
function setEngine(id, flags) {
135141
validateString(id, 'id');
136142
if (flags)
@@ -141,6 +147,8 @@ function setEngine(id, flags) {
141147
if (flags === 0)
142148
flags = ENGINE_METHOD_ALL;
143149

150+
emitOpenSSLEngineDeprecation();
151+
144152
if (typeof _setEngine !== 'function')
145153
throw new ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED();
146154
if (!_setEngine(id, flags))
@@ -955,6 +963,7 @@ module.exports = {
955963
getCurves,
956964
getDataViewOrTypedArrayBuffer,
957965
getHashes,
966+
emitOpenSSLEngineDeprecation,
958967
kHandle,
959968
setEngine,
960969
toBuf,

lib/internal/tls/secure-context.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const {
3333
} = require('internal/validators');
3434

3535
const {
36+
emitOpenSSLEngineDeprecation,
3637
toBuf,
3738
} = require('internal/crypto/util');
3839

@@ -271,6 +272,7 @@ function configSecureContext(context, options = kEmptyObject, name = 'options')
271272

272273
if (typeof privateKeyIdentifier === 'string' &&
273274
typeof privateKeyEngine === 'string') {
275+
emitOpenSSLEngineDeprecation();
274276
if (context.setEngineKey)
275277
context.setEngineKey(privateKeyIdentifier, privateKeyEngine);
276278
else
@@ -332,6 +334,7 @@ function configSecureContext(context, options = kEmptyObject, name = 'options')
332334
}
333335

334336
if (typeof clientCertEngine === 'string') {
337+
emitOpenSSLEngineDeprecation();
335338
if (typeof context.setClientCertEngine !== 'function')
336339
throw new ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED();
337340
else

test/addons/openssl-client-cert-engine/test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ const agentKey = fs.readFileSync(fixture.path('/keys/agent1-key.pem'));
2121
const agentCert = fs.readFileSync(fixture.path('/keys/agent1-cert.pem'));
2222
const agentCa = fs.readFileSync(fixture.path('/keys/ca1-cert.pem'));
2323

24+
common.expectWarning({
25+
DeprecationWarning: {
26+
DEP0183: 'OpenSSL engine-based APIs are deprecated.',
27+
},
28+
});
29+
2430
const serverOptions = {
2531
key: agentKey,
2632
cert: agentCert,

test/addons/openssl-key-engine/test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ const agentKey = fs.readFileSync(fixture.path('/keys/agent1-key.pem'));
2121
const agentCert = fs.readFileSync(fixture.path('/keys/agent1-cert.pem'));
2222
const agentCa = fs.readFileSync(fixture.path('/keys/ca1-cert.pem'));
2323

24+
common.expectWarning({
25+
DeprecationWarning: {
26+
DEP0183: 'OpenSSL engine-based APIs are deprecated.',
27+
},
28+
});
29+
2430
const serverOptions = {
2531
key: agentKey,
2632
cert: agentCert,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
7+
const assert = require('assert');
8+
const crypto = require('crypto');
9+
10+
common.expectWarning({
11+
DeprecationWarning: {
12+
DEP0183: 'OpenSSL engine-based APIs are deprecated.',
13+
},
14+
});
15+
16+
assert.throws(
17+
() => crypto.setEngine('nodejs-test-invalid-engine'),
18+
(err) => {
19+
return err.code === 'ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED' ||
20+
err.code === 'ERR_CRYPTO_ENGINE_UNKNOWN';
21+
},
22+
);

test/parallel/test-tls-clientcertengine-unsupported.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ if (!common.hasCrypto)
66
common.skip('missing crypto');
77

88
const assert = require('assert');
9+
10+
common.expectWarning({
11+
'internal/test/binding':
12+
'These APIs are for internal testing only. Do not use them.',
13+
'DeprecationWarning': {
14+
DEP0183: 'OpenSSL engine-based APIs are deprecated.',
15+
},
16+
});
17+
918
// Monkey-patch SecureContext
1019
const { internalBinding } = require('internal/test/binding');
1120
const binding = internalBinding('crypto');

0 commit comments

Comments
 (0)