• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Flags: --expose-internals
2'use strict';
3const common = require('../common');
4
5if (!common.hasCrypto)
6  common.skip('missing crypto');
7
8const assert = require('assert');
9// Monkey-patch SecureContext
10const { internalBinding } = require('internal/test/binding');
11const binding = internalBinding('crypto');
12const NativeSecureContext = binding.SecureContext;
13
14binding.SecureContext = function() {
15  const rv = new NativeSecureContext();
16  rv.setEngineKey = undefined;
17  return rv;
18};
19
20const tls = require('tls');
21
22{
23  assert.throws(
24    () => {
25      tls.createSecureContext({
26        privateKeyEngine: 'engine',
27        privateKeyIdentifier: 'key'
28      });
29    },
30    {
31      code: 'ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED',
32      message: 'Custom engines not supported by this OpenSSL'
33    }
34  );
35}
36