summaryrefslogtreecommitdiff
path: root/test/parallel/test-tls-keyengine-unsupported.js
diff options
context:
space:
mode:
authorAnton Gerasimov <agerasimov@twilio.com>2019-08-05 12:03:23 +0200
committerRich Trott <rtrott@gmail.com>2019-09-27 15:50:56 -0700
commitc2ce8d05474c38c503b6ac57e94366421c960762 (patch)
treedef403dc2cec32e1e689023669b23a37f9c03b68 /test/parallel/test-tls-keyengine-unsupported.js
parent3de5eae6dbe503485b95bdeb8bddbd67e4613d59 (diff)
downloadnode-new-c2ce8d05474c38c503b6ac57e94366421c960762.tar.gz
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>
Diffstat (limited to 'test/parallel/test-tls-keyengine-unsupported.js')
-rw-r--r--test/parallel/test-tls-keyengine-unsupported.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/parallel/test-tls-keyengine-unsupported.js b/test/parallel/test-tls-keyengine-unsupported.js
new file mode 100644
index 0000000000..149fc4dc31
--- /dev/null
+++ b/test/parallel/test-tls-keyengine-unsupported.js
@@ -0,0 +1,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'
+ }
+ );
+}