Skip to content

openssl+sectrust: fix session reuse#22235

Closed
icing wants to merge 3 commits into
curl:masterfrom
icing:sectrust-session-reuse-fix
Closed

openssl+sectrust: fix session reuse#22235
icing wants to merge 3 commits into
curl:masterfrom
icing:sectrust-session-reuse-fix

Conversation

@icing

@icing icing commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

When TLS is verified via Apple SecTrust, openssl internal state is a verification faiure (that is how it works, we use sectrust when openssl fails to verify and natice ca store is enabled).

OpenSSL stores this verification status inside its TLS session objects. On reuse, we see an unverified session and do not reuse it for a verified connect attempt. While this is a performance penalty for most connections, it fails on ftps:// transfers where servers expect session reuse on DATA connections.

Fix this by remembering that TLS and a session was verified by sectrust and allow reuse of such sessions for new connect attempts that also use sectrust.

@icing icing added TLS appleOS specific to an Apple operating system labels Jul 1, 2026
@icing

icing commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

I swear if the clankers recommend a test case for this, I'll get my M-25 Phased Plasma Pulse-Gun.

@icing icing requested a review from bagder July 1, 2026 09:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses OpenSSL session resumption failures when certificate verification is performed via Apple SecTrust (after OpenSSL verification fails with native CA store enabled). It does so by persisting “verified via SecTrust” state into curl’s session cache and allowing such sessions to be reused on subsequent connections.

Changes:

  • Persist a sectrust_verified flag in Curl_ssl_session and include it in session pack/unpack.
  • Track SecTrust verification state in the OpenSSL backend (ossl_ctx) and propagate it into cached sessions.
  • Relax OpenSSL’s “do not reuse unverified sessions” check to permit reuse for sessions previously verified via SecTrust.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/vtls/vtls_spack.c Adds a new packed-session tag to serialize/deserialize SecTrust verification state.
lib/vtls/vtls_scache.h Extends cached TLS session metadata with a sectrust_verified bit.
lib/vtls/openssl.h Adds OpenSSL-backend state bits for SecTrust verification and whether a reused session was SecTrust-verified.
lib/vtls/openssl.c Propagates SecTrust verification into session cache and permits reuse of SecTrust-verified sessions.
lib/vquic/cf-ngtcp2-cmn.c Updates QUIC OpenSSL session callback to match the updated Curl_ossl_add_session signature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/vtls/openssl.c
icing added 3 commits July 1, 2026 16:07
When TLS is verified via Apple SecTrust, openssl internal state
is a verification faiure (that is how it works, we use sectrust
when openssl fails to verify and natice ca store is enabled).

OpenSSL stores this verification status inside its TLS session
objects. On reuse, we see an unverified session and do not reuse
it for a verified connect attempt. While this is a performance
penalty for most connections, it *fails* on ftps:// transfers
where servers expect session reuse on DATA connections.

Fix this by remembering that TLS and a session was verified
by sectrust and allow reuse of such sessions for new connect
attempts that also use sectrust.
@icing icing force-pushed the sectrust-session-reuse-fix branch from b824c8d to db2624d Compare July 1, 2026 14:13
@bagder bagder closed this in 75c2c88 Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

appleOS specific to an Apple operating system TLS

Development

Successfully merging this pull request may close these issues.

3 participants