MCPcopy Index your code
hub / github.com/nodejs/node / test

Function test

test/parallel/test-tls-client-getephemeralkeyinfo.js:28–75  ·  view source on GitHub ↗
(size, type, name, cipher)

Source from the content-addressed store, hash-verified

26}
27
28function test(size, type, name, cipher) {
29 assert(cipher);
30
31 const options = {
32 key: key,
33 cert: cert,
34 ciphers: cipher,
35 maxVersion: 'TLSv1.2',
36 };
37
38 if (name) options.ecdhCurve = name;
39
40 if (type === 'DH') {
41 if (size === 'auto') {
42 options.dhparam = 'auto';
43 // The DHE parameters selected by OpenSSL depend on the strength of the
44 // certificate's key. For this test, we can assume that the modulus length
45 // of the certificate's key is equal to the size of the DHE parameter, but
46 // that is really only true for a few modulus lengths.
47 ({
48 publicKey: { asymmetricKeyDetails: { modulusLength: size } }
49 } = new X509Certificate(cert));
50 } else {
51 options.dhparam = loadDHParam(size);
52 }
53 }
54
55 const server = tls.createServer(options, common.mustCall((conn) => {
56 assert.strictEqual(conn.getEphemeralKeyInfo(), null);
57 conn.end();
58 }));
59
60 server.on('close', common.mustSucceed());
61
62 server.listen(0, common.mustCall(() => {
63 const client = tls.connect({
64 port: server.address().port,
65 rejectUnauthorized: false
66 }, common.mustCall(function() {
67 const ekeyinfo = client.getEphemeralKeyInfo();
68 assert.strictEqual(ekeyinfo.type, type);
69 assert.strictEqual(ekeyinfo.size, size);
70 assert.strictEqual(ekeyinfo.name, name);
71 server.close();
72 }));
73 client.on('secureConnect', common.mustCall());
74 }));
75}
76
77test(undefined, undefined, undefined, 'AES256-SHA256');
78test('auto', 'DH', undefined, 'DHE-RSA-AES256-GCM-SHA384');

Calls 8

listenMethod · 0.80
loadDHParamFunction · 0.70
connectMethod · 0.65
addressMethod · 0.65
closeMethod · 0.65
assertFunction · 0.50
endMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…