summaryrefslogtreecommitdiff
path: root/test/parallel/test-tls-keyengine-unsupported.js
blob: 149fc4dc316c7cd678d9dd72677f29a9a45b641b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// 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'
    }
  );
}