Skip to content

feat: log TLS secrets to a key log file (SSLKEYLOGFILE) - #47

Open
pgit wants to merge 3 commits into
boost-httpfrom
tls-keylog
Open

pgit wants to merge 3 commits into
boost-httpfrom
tls-keylog

Conversation

@pgit

@pgit pgit commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Stacked on #46 (boost-http); this PR is the last commit only, and will retarget to master once #46 is merged.

What

server::Config, client::Config and quic::Config get tls_keylog_file. When it is set, every handshake, over TCP and QUIC, appends its secrets to that file in the NSS key log format that Wireshark reads. It is empty by default, and then nothing is logged.

  • The file is opened with the TLS context and created with mode 0600. Each line is appended with a single write(), so servers, clients and curl can share one file.
  • A file that cannot be opened makes the Server's construction fail, or the connect.
  • The library does not read SSLKEYLOGFILE itself. The server and client programs do, and server also takes --keylog FILE.
  • docs/capture.rst describes the option next to the existing curl/tshark recipe.

Limitation

On COROSIO only QUIC is logged. corosio's tls_context and stream expose neither SSL_CTX nor SSL, so TLS over TCP logs a warning and continues without a key log.

Tests

In test/test_client_connect.cpp, for HTTP/1.1, HTTP/2 and HTTP/3:

  • ClientTlsKeyLog.WHEN_keylog_file_is_set_THEN_both_ends_log_the_same_secrets
  • ClientTlsBadKeyLog.WHEN_keylog_file_cannot_be_opened_THEN_connect_fails

🤖 Generated with Claude Code

pgit and others added 3 commits November 14, 2026 20:38
HTTP/1.1 now runs on Boost.HTTP's sans-I/O parser and serializer, and
Fields is boost::http::fields. Nothing in any tree includes Beast any
more.

- cmake/http.cmake FetchContents cppalliance/http at a pinned SHA of
  develop for every tree, with capy at the existing pin, and builds its
  protocol core only, as anyhttp_http. Two patches are applied, both to
  be proposed upstream: parser::release_buffered_data() (a stub on
  develop, needed for the h2c upgrade) and fields_base::reserve_bytes()
  keeping the field table aligned (found by UBSAN).
- h1/io.hpp drives the parser and serializer on the runtime layer; one
  parser and one serializer per session, readers and writers use them
  in turn.
- A request released before its body is complete now shuts the send
  side down, so that neither peer waits forever for the rest of it.
- Public API: Fields iterates as .name/.value and adds with append();
  client::Message derives from boost::http::response with a body();
  new errors::end_of_stream and reason_phrase().
- Buffer is detail::FlatBuffer instead of beast::flat_buffer; the
  installed package carries anyhttp::http and capy along.
- src/issues/beast_issue_3032.cpp is gone with Beast.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ffer in bounds

Two findings of the review of eda7a77:

- A response to HEAD has no payload, but its 'Content-Length' is still
  what it announced: Reader::content_length() reports it, as it did with
  Beast and as HTTP/2 and HTTP/3 do, instead of 0. The HEAD test checks
  the accessor as well as the field now.
- parser::release_buffered_data() (cmake/patches) rebuilt the circular
  buffer with the workspace's whole capacity from a pointer that is not
  its base. Harmless, as only start() and reset() follow, but it claims
  memory past the storage: the buffer now holds the unconsumed body and
  no more.

Changing a patch exposed that the patch step runs again only when its
command changes, and that a changed patch does not apply over its earlier
version: the command now carries each patch's hash, and restores the
pristine files before applying them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
server::Config, client::Config and quic::Config get tls_keylog_file: every
handshake, over TCP and QUIC, appends its secrets to it in the NSS key log
format that Wireshark reads. Empty, the default, logs nothing. The file is
opened with the TLS context, created with mode 0600 and appended to one
write() per line, so servers, clients and curl can share it; one that cannot
be opened fails the Server's construction or the connect.

The library does not read SSLKEYLOGFILE; the server and client programs do
(server --keylog FILE as well).

COROSIO logs QUIC only: corosio's tls_context and stream expose neither
SSL_CTX nor SSL, so TLS over TCP warns and goes on without.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant