mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 22:40:57 +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>
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const https = require('https');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const server = https.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',
|
|
}, (req, res) => {
|
|
res.end('bye');
|
|
}).listen(() => {
|
|
https.get({
|
|
port: server.address().port,
|
|
rejectUnauthorized: false,
|
|
}, (res) => {
|
|
res.resume();
|
|
res.on('end', () => {
|
|
// Trigger TLS connection reuse
|
|
https.get({
|
|
port: server.address().port,
|
|
rejectUnauthorized: false,
|
|
}, (res) => {
|
|
server.close();
|
|
res.resume();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
const verifyKeylog = (line, tlsSocket) => {
|
|
assert(Buffer.isBuffer(line));
|
|
assert.strictEqual(tlsSocket.encrypted, true);
|
|
};
|
|
server.on('keylog', common.mustCall(verifyKeylog, 10));
|
|
https.globalAgent.on('keylog', common.mustCall(verifyKeylog, 10));
|