-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https: add client support for TLS keylog events
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: #30053 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
3b4b0de
commit dc521b0
Showing
4 changed files
with
100 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters