• line {Buffer} Line of ASCII text, in NSS SSLKEYLOGFILE format.
    • tlsSocket {tls.TLSSocket} The tls.TLSSocket instance on which it was generated.

    The keylog event is emitted when key material is generated or received by a connection to this server (typically before handshake has completed, but not necessarily). This keying material can be stored for debugging, as it allows captured TLS traffic to be decrypted. It may be emitted multiple times for each socket.

    A typical use case is to append received lines to a common text file, which is later used by software (such as Wireshark) to decrypt the traffic:

    1. const logFile = fs.createWriteStream('/tmp/ssl-keys.log', { flags: 'a' });
    2. // ...
    3. server.on('keylog', (line, tlsSocket) => {
    4. if (tlsSocket.remoteAddress !== '...')
    5. return; // Only log keys for a particular IP
    6. logFile.write(line);
    7. });