crypto: remove deprecated legacy API

The `crypto.Credentials` legacy API has been Runtime deprecated since
v0.11.13 and users had been adviced to use `tls.SecureContext` instead.

PR-URL: https://github.com/nodejs/node/pull/21153
Fixes: https://github.com/nodejs/node/issues/20793
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Antoine du HAMEL 2018-06-25 23:31:43 +02:00 committed by Vse Mozhet Byt
parent 3950a3e0b1
commit d2ee7d64aa
5 changed files with 4 additions and 66 deletions

View File

@ -1415,25 +1415,6 @@ something has to be unpredictable and unique, but does not have to be secret;
it is important to remember that an attacker must not be able to predict ahead it is important to remember that an attacker must not be able to predict ahead
of time what a given IV will be. of time what a given IV will be.
### crypto.createCredentials(details)
<!-- YAML
added: v0.1.92
deprecated: v0.11.13
-->
> Stability: 0 - Deprecated: Use [`tls.createSecureContext()`][] instead.
- `details` {Object} Identical to [`tls.createSecureContext()`][].
- Returns: {tls.SecureContext}
The `crypto.createCredentials()` method is a deprecated function for creating
and returning a `tls.SecureContext`. It should not be used. Replace it with
[`tls.createSecureContext()`][] which has the exact same arguments and return
value.
Returns a `tls.SecureContext`, as-if [`tls.createSecureContext()`][] had been
called.
### crypto.createDecipher(algorithm, password[, options]) ### crypto.createDecipher(algorithm, password[, options])
<!-- YAML <!-- YAML
added: v0.1.94 added: v0.1.94
@ -2750,7 +2731,6 @@ the `crypto`, `tls`, and `https` modules and are generally specific to OpenSSL.
[`sign.update()`]: #crypto_sign_update_data_inputencoding [`sign.update()`]: #crypto_sign_update_data_inputencoding
[`stream.transform` options]: stream.html#stream_new_stream_transform_options [`stream.transform` options]: stream.html#stream_new_stream_transform_options
[`stream.Writable` options]: stream.html#stream_constructor_new_stream_writable_options [`stream.Writable` options]: stream.html#stream_constructor_new_stream_writable_options
[`tls.createSecureContext()`]: tls.html#tls_tls_createsecurecontext_options
[`verify.update()`]: #crypto_verify_update_data_inputencoding [`verify.update()`]: #crypto_verify_update_data_inputencoding
[`verify.verify()`]: #crypto_verify_verify_object_signature_signatureformat [`verify.verify()`]: #crypto_verify_verify_object_signature_signatureformat
[AEAD algorithms]: https://en.wikipedia.org/wiki/Authenticated_encryption [AEAD algorithms]: https://en.wikipedia.org/wiki/Authenticated_encryption

View File

@ -142,17 +142,17 @@ undefined `digest` will throw a `TypeError`.
<a id="DEP0010"></a> <a id="DEP0010"></a>
### DEP0010: crypto.createCredentials ### DEP0010: crypto.createCredentials
Type: Runtime Type: End-of-Life
The [`crypto.createCredentials()`][] API is deprecated. Please use The `crypto.createCredentials()` API was removed. Please use
[`tls.createSecureContext()`][] instead. [`tls.createSecureContext()`][] instead.
<a id="DEP0011"></a> <a id="DEP0011"></a>
### DEP0011: crypto.Credentials ### DEP0011: crypto.Credentials
Type: Runtime Type: End-of-Life
The `crypto.Credentials` class is deprecated. Please use [`tls.SecureContext`][] The `crypto.Credentials` class was removed. Please use [`tls.SecureContext`][]
instead. instead.
<a id="DEP0012"></a> <a id="DEP0012"></a>
@ -1020,7 +1020,6 @@ The option `produceCachedData` has been deprecated. Use
[`console.log()`]: console.html#console_console_log_data_args [`console.log()`]: console.html#console_console_log_data_args
[`crypto.createCipher()`]: crypto.html#crypto_crypto_createcipher_algorithm_password_options [`crypto.createCipher()`]: crypto.html#crypto_crypto_createcipher_algorithm_password_options
[`crypto.createCipheriv()`]: crypto.html#crypto_crypto_createcipheriv_algorithm_key_iv_options [`crypto.createCipheriv()`]: crypto.html#crypto_crypto_createcipheriv_algorithm_key_iv_options
[`crypto.createCredentials()`]: crypto.html#crypto_crypto_createcredentials_details
[`crypto.createDecipher()`]: crypto.html#crypto_crypto_createdecipher_algorithm_password_options [`crypto.createDecipher()`]: crypto.html#crypto_crypto_createdecipher_algorithm_password_options
[`crypto.createDecipheriv()`]: crypto.html#crypto_crypto_createdecipheriv_algorithm_key_iv_options [`crypto.createDecipheriv()`]: crypto.html#crypto_crypto_createdecipheriv_algorithm_key_iv_options
[`crypto.DEFAULT_ENCODING`]: crypto.html#crypto_crypto_default_encoding [`crypto.DEFAULT_ENCODING`]: crypto.html#crypto_crypto_default_encoding

View File

@ -228,23 +228,5 @@ Object.defineProperties(exports, {
configurable: false, configurable: false,
enumerable: true, enumerable: true,
value: constants value: constants
},
// Legacy API
createCredentials: {
configurable: true,
enumerable: true,
get: deprecate(() => {
return require('tls').createSecureContext;
}, 'crypto.createCredentials is deprecated. ' +
'Use tls.createSecureContext instead.', 'DEP0010')
},
Credentials: {
configurable: true,
enumerable: true,
get: deprecate(function() {
return require('tls').SecureContext;
}, 'crypto.Credentials is deprecated. ' +
'Use tls.SecureContext instead.', 'DEP0011')
} }
}); });

View File

@ -19,7 +19,6 @@ const TEST_CASES = {
'DiffieHellman': [1024], 'DiffieHellman': [1024],
'DiffieHellmanGroup': ['modp5'], 'DiffieHellmanGroup': ['modp5'],
'ECDH': ['prime256v1'], 'ECDH': ['prime256v1'],
'Credentials': []
}; };
if (!common.hasFipsCrypto) { if (!common.hasFipsCrypto) {

View File

@ -1,22 +0,0 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const crypto = require('crypto');
const tls = require('tls');
common.expectWarning('DeprecationWarning', [
['crypto.Credentials is deprecated. Use tls.SecureContext instead.',
'DEP0011'],
['crypto.createCredentials is deprecated. Use tls.createSecureContext ' +
'instead.', 'DEP0010']
]);
// Accessing the deprecated function is enough to trigger the warning event.
// It does not need to be called. So the assert serves the purpose of both
// triggering the warning event and confirming that the deprecated function is
// mapped to the correct non-deprecated function.
assert.strictEqual(crypto.Credentials, tls.SecureContext);
assert.strictEqual(crypto.createCredentials, tls.createSecureContext);