(size, type, name, cipher)
| 26 | } |
| 27 | |
| 28 | function 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 | |
| 77 | test(undefined, undefined, undefined, 'AES256-SHA256'); |
| 78 | test('auto', 'DH', undefined, 'DHE-RSA-AES256-GCM-SHA384'); |
no test coverage detected
searching dependent graphs…