mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 13:47:16 +00:00

This commit makes the crypto builtin an internal builtin, and changes usage of the builtin from using process.binding('crypto') to use internalBinding instead. Refs: https://github.com/nodejs/node/issues/22160 PR-URL: https://github.com/nodejs/node/pull/22426 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
30 lines
723 B
JavaScript
30 lines
723 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
const common = require('../common');
|
|
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
// Monkey-patch SecureContext
|
|
const { internalBinding } = require('internal/test/binding');
|
|
const binding = internalBinding('crypto');
|
|
const NativeSecureContext = binding.SecureContext;
|
|
|
|
binding.SecureContext = function() {
|
|
const rv = new NativeSecureContext();
|
|
rv.setClientCertEngine = undefined;
|
|
return rv;
|
|
};
|
|
|
|
const tls = require('tls');
|
|
|
|
{
|
|
common.expectsError(
|
|
() => { tls.createSecureContext({ clientCertEngine: 'Cannonmouth' }); },
|
|
{
|
|
code: 'ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED',
|
|
message: 'Custom engines not supported by this OpenSSL'
|
|
}
|
|
);
|
|
}
|