Share the TLS session cache across requests - #105
Merged
Conversation
Add CURL_LOCK_DATA_SSL_SESSION to the curl share, so a new connection to an https origin resumes a TLS session instead of a full handshake. Every fetch still opens its own socket, so the address guard runs on each.
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.
What
Add
CURL_LOCK_DATA_SSL_SESSIONto the curl share, alongside the DNS cache it already shares. A new connection to anhttpsorigin can resume a TLS session instead of running a full handshake.Why
This is the safe part of the connection-reuse work. Full keep-alive connection reuse is not included: a reused connection skips curl's open-socket callback, which is where the network guard checks the resolved address, so reuse would let a connection opened under one configuration serve a later request whose configuration refuses that address — an SSRF-guard bypass. Testing confirmed
CURLOPT_PREREQFUNCTIONdid not reliably re-check reused connections here, so connection reuse is left for a separate, security-reviewed change. Sharing only the session cache keeps every fetch opening its own socket, so the guard runs on each.Verify
Run
make -C test test; all 267 cases pass. The fixture origin ishttp, so the session cache has no effect on the golden output; the benefit is onhttpsorigins in production.