Repository navigation
internal/ctlog: prerender get-roots responses - #77
Open
lsautia-godaddy wants to merge 2 commits into
Open
lsautia-godaddy wants to merge 2 commits into
lsautia-godaddy wants to merge 2 commits into
Conversation
lsautia-godaddy
force-pushed
the
feat/prerender-get-roots
branch
from
November 12, 2026 20:45
ddfeef7 to
f9e5863
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each
get-rootsrequest currently collects the accepted certificates and serializes the entire response to JSON. This repeats the certificate traversal and base64/JSON encoding even when the accepted roots have not changed.Render the response when a log loads and when its accepted root set changes. The existing
/ct/v1/get-rootshandler now writes that immutable response directly, removing serialization from the request path.Implementation
rootsJSONsnapshot to each log and initialize it from persisted roots inLoadLog, including an emptycertificatesarray when there are no roots.SetRootsFromPEM, skip an identical PEM refresh entirely. If the PEM changes but the accepted certificate set is unchanged (ordering, comments, or duplicates), preserve the existing JSON buffer while persisting the updated PEM.rootsMu, after the backend upload succeeds. Parsing or upload failures retain the previous roots and response.The retained memory is one serialized JSON response per log, approximately the base64 size of the certificates plus JSON syntax (roughly 4/3 of the total DER bytes). Requests share that buffer. A changed root set allocates a replacement; an old snapshot remains reachable only while existing requests use it, then becomes eligible for garbage collection. An unchanged accepted set reuses the buffer.
The response retains its JSON structure, trailing newline, content type, and CORS header. HTTP cache headers remain under operator control; this change adds no
Cache-Controlpolicy.Validation
Added tests for response-buffer reuse, root additions/removals, PEM reordering/comments/duplicates, startup from persisted and empty roots, invalid PEM/DER, backend upload failure and retry, updates during an in-flight response, and concurrent readers/root updates. The full CT log suite,
go test -short -race ./internal/ctlog, command builds, and command-hsmoke checks passed.Also ran the actual application locally over verified HTTPS from clean commit
ddfeef7, with independent TLS and mark logs, filesystem storage, and SQLite checkpoint/cache databases. All 14 runtime checks passed, including:get-rootsresponses with the expected bytes and headers.The runtime check uses custom PEM reloads through SIGHUP. Live CCADB fetching, the 15-minute timer, and remote object storage were not exercised. These are functional checks; no production performance or memory measurements are claimed.