Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -6057,18 +6057,24 @@ added: v15.6.0
<!-- YAML
added: v0.11.11
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/63966
description: Runtime deprecation.
- version:
- v22.4.0
- v20.16.0
pr-url: https://github.com/nodejs/node/pull/53329
description: Custom engine support in OpenSSL 3 is deprecated.
-->

> Stability: 0 - Deprecated

* `engine` {string}
* `flags` {crypto.constants} **Default:** `crypto.constants.ENGINE_METHOD_ALL`

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

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

Expand Down
5 changes: 4 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -4058,14 +4058,17 @@ that are shorter than the default authentication tag length (i.e., shorter than

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/63966
description: Runtime deprecation.
- version:
- v22.4.0
- v20.16.0
pr-url: https://github.com/nodejs/node/pull/53329
description: Documentation-only deprecation.
-->

Type: Documentation-only
Type: Runtime

OpenSSL 3 has deprecated support for custom engines with a recommendation to
switch to its new provider model. The `clientCertEngine` option for
Expand Down
3 changes: 3 additions & 0 deletions doc/api/https.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ a `timeout` of 5 seconds.
<!-- YAML
added: v0.3.6
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/63966
description: The `clientCertEngine` option is runtime deprecated.
- version:
- v22.4.0
- v20.16.0
Expand Down
7 changes: 7 additions & 0 deletions doc/api/tls.md
Original file line number Diff line number Diff line change
Expand Up @@ -1895,6 +1895,10 @@ argument.
<!-- YAML
added: v0.11.13
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/63966
description: The `clientCertEngine`, `privateKeyEngine` and
`privateKeyIdentifier` options are runtime deprecated.
- version:
- v22.9.0
- v20.18.0
Expand Down Expand Up @@ -2104,6 +2108,9 @@ permissible, use 2048 bits or larger for stronger security.
<!-- YAML
added: v0.3.2
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/63966
description: The `clientCertEngine` option is runtime deprecated.
- version:
- v22.4.0
- v20.16.0
Expand Down
9 changes: 9 additions & 0 deletions lib/internal/crypto/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const {
cachedResult,
emitExperimentalWarning,
filterDuplicateStrings,
getDeprecationWarningEmitter,
lazyDOMException,
setOwnProperty,
} = require('internal/util');
Expand Down Expand Up @@ -131,6 +132,11 @@ const getCiphers = cachedResult(() => filterDuplicateStrings(_getCiphers()));
const getHashes = cachedResult(() => filterDuplicateStrings(_getHashes()));
const getCurves = cachedResult(() => filterDuplicateStrings(_getCurves()));

const emitOpenSSLEngineDeprecation = getDeprecationWarningEmitter(
'DEP0183',
'OpenSSL engine-based APIs are deprecated.',
);

function setEngine(id, flags) {
validateString(id, 'id');
if (flags)
Expand All @@ -141,6 +147,8 @@ function setEngine(id, flags) {
if (flags === 0)
flags = ENGINE_METHOD_ALL;

emitOpenSSLEngineDeprecation();

if (typeof _setEngine !== 'function')
throw new ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED();
if (!_setEngine(id, flags))
Expand Down Expand Up @@ -955,6 +963,7 @@ module.exports = {
getCurves,
getDataViewOrTypedArrayBuffer,
getHashes,
emitOpenSSLEngineDeprecation,
kHandle,
setEngine,
toBuf,
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/tls/secure-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const {
} = require('internal/validators');

const {
emitOpenSSLEngineDeprecation,
toBuf,
} = require('internal/crypto/util');

Expand Down Expand Up @@ -233,6 +234,7 @@ function configSecureContext(context, options = kEmptyObject, name = 'options')

if (typeof privateKeyIdentifier === 'string' &&
typeof privateKeyEngine === 'string') {
emitOpenSSLEngineDeprecation();
if (context.setEngineKey)
context.setEngineKey(privateKeyIdentifier, privateKeyEngine);
else
Expand Down Expand Up @@ -294,6 +296,7 @@ function configSecureContext(context, options = kEmptyObject, name = 'options')
}

if (typeof clientCertEngine === 'string') {
emitOpenSSLEngineDeprecation();
if (typeof context.setClientCertEngine !== 'function')
throw new ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED();
else
Expand Down
6 changes: 6 additions & 0 deletions test/addons/openssl-client-cert-engine/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ const agentKey = fs.readFileSync(fixture.path('/keys/agent1-key.pem'));
const agentCert = fs.readFileSync(fixture.path('/keys/agent1-cert.pem'));
const agentCa = fs.readFileSync(fixture.path('/keys/ca1-cert.pem'));

common.expectWarning({
DeprecationWarning: {
DEP0183: 'OpenSSL engine-based APIs are deprecated.',
},
});

const serverOptions = {
key: agentKey,
cert: agentCert,
Expand Down
6 changes: 6 additions & 0 deletions test/addons/openssl-key-engine/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ const agentKey = fs.readFileSync(fixture.path('/keys/agent1-key.pem'));
const agentCert = fs.readFileSync(fixture.path('/keys/agent1-cert.pem'));
const agentCa = fs.readFileSync(fixture.path('/keys/ca1-cert.pem'));

common.expectWarning({
DeprecationWarning: {
DEP0183: 'OpenSSL engine-based APIs are deprecated.',
},
});

const serverOptions = {
key: agentKey,
cert: agentCert,
Expand Down
22 changes: 22 additions & 0 deletions test/parallel/test-crypto-dep0183.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');
const crypto = require('crypto');

common.expectWarning({
DeprecationWarning: {
DEP0183: 'OpenSSL engine-based APIs are deprecated.',
},
});

assert.throws(
() => crypto.setEngine('nodejs-test-invalid-engine'),
(err) => {
return err.code === 'ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED' ||
err.code === 'ERR_CRYPTO_ENGINE_UNKNOWN';
},
);
9 changes: 9 additions & 0 deletions test/parallel/test-tls-clientcertengine-unsupported.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');

common.expectWarning({
'internal/test/binding':
'These APIs are for internal testing only. Do not use them.',
'DeprecationWarning': {
DEP0183: 'OpenSSL engine-based APIs are deprecated.',
},
});

// Monkey-patch SecureContext
const { internalBinding } = require('internal/test/binding');
const binding = internalBinding('crypto');
Expand Down
13 changes: 10 additions & 3 deletions test/parallel/test-tls-error-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ if (!common.hasCrypto)
const assert = require('assert');
const tls = require('tls');

const secureContext = tls.createSecureContext();
if (typeof secureContext.context.setClientCertEngine !== 'function')
common.skip('OpenSSL dropped engine support');

common.expectWarning({
DeprecationWarning: {
DEP0183: 'OpenSSL engine-based APIs are deprecated.',
},
});

assert.throws(() => {
tls.createSecureContext({ clientCertEngine: 'x' });
}, (err) => {
if (err.code === 'ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED')
common.skip('OpenSSL dropped engine support');

return err.name === 'Error' &&
/could not load the shared library/.test(err.message) &&
Array.isArray(err.opensslErrorStack) &&
Expand Down
9 changes: 9 additions & 0 deletions test/parallel/test-tls-keyengine-unsupported.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');

common.expectWarning({
'internal/test/binding':
'These APIs are for internal testing only. Do not use them.',
'DeprecationWarning': {
DEP0183: 'OpenSSL engine-based APIs are deprecated.',
},
});

// Monkey-patch SecureContext
const { internalBinding } = require('internal/test/binding');
const binding = internalBinding('crypto');
Expand Down
Loading