Skip to content

Share the TLS session cache across requests - #105

Merged
beetlebugorg merged 1 commit into
mainfrom
perf/share-tls-sessions
Aug 28, 2026
Merged

Share the TLS session cache across requests#105
beetlebugorg merged 1 commit into
mainfrom
perf/share-tls-sessions

Conversation

@beetlebugorg

@beetlebugorg beetlebugorg commented Aug 28, 2026

Copy link
Copy Markdown
Owner

What

Add CURL_LOCK_DATA_SSL_SESSION to the curl share, alongside the DNS cache it already shares. A new connection to an https origin 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_PREREQFUNCTION did 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 is http, so the session cache has no effect on the golden output; the benefit is on https origins in production.

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.
@beetlebugorg
beetlebugorg merged commit e5e28ff into main Aug 28, 2026
5 checks passed
@beetlebugorg
beetlebugorg deleted the perf/share-tls-sessions branch August 28, 2026 19:46
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