Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 121245f

Browse filesBrowse files
TrottMylesBorins
authored andcommitted
test: add tls clientcertengine tests
1 parent 7d49bd0 commit 121245f
Copy full SHA for 121245f

File tree

Expand file treeCollapse file tree

3 files changed

+58
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+58
-0
lines changed
Open diff view settings
Collapse file
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
7+
const assert = require('assert');
8+
const tls = require('tls');
9+
10+
{
11+
assert.throws(
12+
() => { tls.createSecureContext({ clientCertEngine: 0 }); },
13+
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE',
14+
message: / Received type number$/ }));
15+
}
Collapse file
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
7+
// Monkey-patch SecureContext
8+
const binding = process.binding('crypto');
9+
const NativeSecureContext = binding.SecureContext;
10+
11+
binding.SecureContext = function() {
12+
const rv = new NativeSecureContext();
13+
rv.setClientCertEngine = undefined;
14+
return rv;
15+
};
16+
17+
const assert = require('assert');
18+
const tls = require('tls');
19+
20+
{
21+
assert.throws(
22+
() => { tls.createSecureContext({ clientCertEngine: 'Cannonmouth' }); },
23+
common.expectsError({
24+
code: 'ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED',
25+
message: 'Custom engines not supported by this OpenSSL'
26+
})
27+
);
28+
}
Collapse file
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
7+
const assert = require('assert');
8+
const tls = require('tls');
9+
10+
{
11+
const server = tls.createServer();
12+
assert.strictEqual(server.clientCertEngine, undefined);
13+
server.setOptions({ clientCertEngine: 'Cannonmouth' });
14+
assert.strictEqual(server.clientCertEngine, 'Cannonmouth');
15+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.