Interface KeyLog

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface KeyLog
Receives TLS traffic secrets in the NSS key log format (SSLKEYLOGFILE), which Wireshark reads to decrypt QUIC packets. A debugging aid only: whoever holds the log can read the traffic.

The labels are those of TLS 1.3: CLIENT_HANDSHAKE_TRAFFIC_SECRET, SERVER_HANDSHAKE_TRAFFIC_SECRET, CLIENT_TRAFFIC_SECRET_0 and SERVER_TRAFFIC_SECRET_0. Implementations must be thread-safe: connections log from their own threads.

  • Method Summary

    Modifier and Type
    Method
    Description
    static KeyLog
    file(Path file)
    A key log that appends to a file, creating it if needed.
    static KeyLog
    The key log named by the SSLKEYLOGFILE environment variable.
    static String
    line(String label, byte[] clientRandom, byte[] secret)
    Formats one line of the key log file.
    void
    log(String label, byte[] clientRandom, byte[] secret)
    Logs one secret.
  • Method Details

    • log

      void log(String label, byte[] clientRandom, byte[] secret)
      Logs one secret.
      Parameters:
      label - the NSS key log label
      clientRandom - the ClientHello random that identifies the handshake
      secret - the secret
    • line

      static String line(String label, byte[] clientRandom, byte[] secret)
      Formats one line of the key log file.
      Parameters:
      label - the label
      clientRandom - the client random
      secret - the secret
      Returns:
      the line, without a line terminator
    • file

      static KeyLog file(Path file)
      A key log that appends to a file, creating it if needed.
      Parameters:
      file - the file, such as the one named by the SSLKEYLOGFILE environment variable
      Returns:
      the key log; each line is written and flushed under a lock
    • fromEnvironment

      static KeyLog fromEnvironment()
      The key log named by the SSLKEYLOGFILE environment variable.
      Returns:
      a file key log, or null if the variable is not set