mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 13:40:37 +00:00

The keylog event is implemented on TLS sockets, but client HTTPS uses TLS sockets managed by an agent, so accessing the underlying socket before the TLS handshake completed was not possible. Note that server HTTPS already supports the keylog event because it inherits from the TLS server. PR-URL: https://github.com/nodejs/node/pull/30053 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
37 lines
951 B
JavaScript
37 lines
951 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const tls = require('tls');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const server = tls.createServer({
|
|
key: fixtures.readKey('agent2-key.pem'),
|
|
cert: fixtures.readKey('agent2-cert.pem'),
|
|
// Amount of keylog events depends on negotiated protocol
|
|
// version, so force a specific one:
|
|
minVersion: 'TLSv1.3',
|
|
maxVersion: 'TLSv1.3',
|
|
}).listen(() => {
|
|
const client = tls.connect({
|
|
port: server.address().port,
|
|
rejectUnauthorized: false,
|
|
});
|
|
|
|
server.on('keylog', common.mustCall((line, tlsSocket) => {
|
|
assert(Buffer.isBuffer(line));
|
|
assert.strictEqual(tlsSocket.encrypted, true);
|
|
}, 5));
|
|
client.on('keylog', common.mustCall((line) => {
|
|
assert(Buffer.isBuffer(line));
|
|
}, 5));
|
|
|
|
client.once('secureConnect', () => {
|
|
server.close();
|
|
client.end();
|
|
});
|
|
});
|