node/test/parallel/test-tls-keyengine-unsupported.js
Anton Gerasimov c2ce8d0547 tls: add option for private keys for OpenSSL engines
Add `privateKeyIdentifier` and `privateKeyEngine` options
to get private key from an OpenSSL engine in tls.createSecureContext().

PR-URL: https://github.com/nodejs/node/pull/28973
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
2019-09-27 15:50:56 -07:00

35 lines
772 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.setEngineKey = undefined;
return rv;
};
const tls = require('tls');
{
common.expectsError(
() => {
tls.createSecureContext({
privateKeyEngine: 'engine',
privateKeyIdentifier: 'key'
});
},
{
code: 'ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED',
message: 'Custom engines not supported by this OpenSSL'
}
);
}