Skip to content

Honor TLS handshake hook pauses on BoringSSL - #13729

Merged
maskit merged 1 commit into
apache:masterfrom
maskit:boringssl-handshake-hook-pause
Oct 2, 2026
Merged

maskit merged 1 commit into
apache:masterfrom
maskit:boringssl-handshake-hook-pause

Conversation

@maskit

@maskit maskit commented Sep 24, 2026

Copy link
Copy Markdown
Member

On BoringSSL builds, a plugin that parks the handshake in the client hello or cert hook is not waited for. The select certificate callback dropped the retry from the client hello step and mapped a cert hook pause to success, so the handshake carried on without the plugin.

The callback has behaved this way since it was added in #8014. The rate_limit_sni_expiry and tls_hooks_close_while_parked tests from #13406 rely on the pause and fail on BoringSSL builds without this change.

Changes

  • The select certificate callback returns a retry when the client hello hook or the cert hook pauses.
  • BoringSSL calls the callback again from the top once the hook reenables. After a cert hook pause, the client hello and servername steps are skipped rather than run twice. TLSEventSupport::reached_cert_hooks() tells the callback which case it is in.

OpenSSL builds use a separate callback and are unaffected.

On BoringSSL builds, a plugin that parks the handshake in the client
hello or cert hook is not waited for. The select certificate callback
dropped the retry from the client hello step and mapped a cert hook
pause to success, so the handshake carried on without the plugin.

Return a retry for both. BoringSSL then calls the callback again from
the top, so after a cert hook pause the client hello and servername
steps are skipped rather than run twice. OpenSSL builds use a separate
callback and are unaffected.

The callback has behaved this way since BoringSSL support for it was
added in apache#8014. The rate_limit_sni_expiry and
tls_hooks_close_while_parked tests from apache#13406 rely on the pause and
fail on BoringSSL builds without this change.
@maskit maskit added this to the 11.0.0 milestone Sep 24, 2026
@maskit maskit added the TLS label Sep 24, 2026
Copilot AI lite review requested due to automatic review settings September 24, 2026 15:20
@maskit maskit self-assigned this Sep 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Critical certificate-hook resume issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity

Open (2)
What changed in this PR

Updates BoringSSL TLS certificate callbacks to correctly pause and resume handshake hooks.

Changes:

  • Propagates paused ClientHello and certificate hooks as retries.
  • Tracks certificate-hook progress to avoid repeating completed stages.
  • Adds a certificate-phase state helper.
File Description
src/​iocore/​net/​TLSEventSupport.cc Adds certificate-phase state detection.
src/​iocore/​net/​SSLUtils.cc Updates BoringSSL callback retry handling.
include/​iocore/​net/​TLSEventSupport.h Declares the new state helper.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +1071 to +1075
if (es == nullptr || !es->reached_cert_hooks()) {
res = ssl_client_hello_callback(client_hello);
if (res != ssl_select_cert_success) {
return res;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The resumed call ending up in HANDSHAKE_HOOKS_CLIENT_CERT is not specific to this change. OpenSSL re-invokes cert_cb after a -1 pause as well, so OpenSSL builds already re-run selectCertificate() and start the verify-client hook list with TS_EVENT_SSL_CERT in the same situation. This PR brings BoringSSL onto that shared path; fixing ssl_cert_callback() for both backends is tracked in #13730.

Comment on lines +384 to +385
case SSLHandshakeHookState::HANDSHAKE_HOOKS_CLIENT_CERT:
case SSLHandshakeHookState::HANDSHAKE_HOOKS_CLIENT_CERT_INVOKE:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The resumed call ending up in HANDSHAKE_HOOKS_CLIENT_CERT is not specific to this change. OpenSSL re-invokes cert_cb after a -1 pause as well, so OpenSSL builds already re-run selectCertificate() and start the verify-client hook list with TS_EVENT_SSL_CERT in the same situation. This PR brings BoringSSL onto that shared path; fixing ssl_cert_callback() for both backends is tracked in #13730.

@maskit

maskit commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

[approve ci rocky]

@bryancall bryancall added the Bug label Sep 25, 2026
@bryancall
bryancall requested a review from moonchen September 28, 2026 22:23

@moonchen moonchen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Keeping this PR focused on BoringSSL callback sequencing and retry handling makes sense.

Let’s track the shared callback fixes in #13730:

  • ClientHello: Skip hooks that have already completed.
  • Certificate: Skip completed certificate selection and hooks, preserve the plugin-selected certificate, and finish any remaining CA and session-ticket setup.

These follow-ups should cover both OpenSSL and BoringSSL and land before we release this retry behavior.

@maskit
maskit enabled auto-merge (squash) October 2, 2026 20:58
@maskit
maskit disabled auto-merge October 2, 2026 20:59
@maskit
maskit merged commit 1a7dbe8 into apache:master Oct 2, 2026
14 checks passed
@github-project-automation github-project-automation Bot moved this to For v10.2.1 in ATS v10.2.x Oct 2, 2026
moonchen added a commit to moonchen/trafficserver that referenced this pull request Oct 2, 2026
An omitted dest_ip also claims the wildcard, making callback retention
depend on certificate load order. Give foo.com a nonmatching address so
bar.com is the only wildcard and the cert callback retries on both TLS
backends. BoringSSL coverage includes the adapter fix from apache#13729.
moonchen added a commit to moonchen/trafficserver that referenced this pull request Oct 5, 2026
An omitted dest_ip also claims the wildcard, making callback retention
depend on certificate load order. Give foo.com a nonmatching address so
bar.com is the only wildcard and the cert callback retries on both TLS
backends. BoringSSL coverage includes the adapter fix from apache#13729.
cmcfarlen pushed a commit that referenced this pull request Oct 7, 2026
On BoringSSL builds, a plugin that parks the handshake in the client
hello or cert hook is not waited for. The select certificate callback
dropped the retry from the client hello step and mapped a cert hook
pause to success, so the handshake carried on without the plugin.

Return a retry for both. BoringSSL then calls the callback again from
the top, so after a cert hook pause the client hello and servername
steps are skipped rather than run twice. OpenSSL builds use a separate
callback and are unaffected.

The callback has behaved this way since BoringSSL support for it was
added in #8014. The rate_limit_sni_expiry and
tls_hooks_close_while_parked tests from #13406 rely on the pause and
fail on BoringSSL builds without this change.

(cherry picked from commit 1a7dbe8)
@cmcfarlen cmcfarlen modified the milestones: 11.0.0, 10.2.1 Oct 7, 2026
@cmcfarlen

Copy link
Copy Markdown
Contributor

Cherry-picked to the 10.2.x branch as 855e21c for the 10.2.1 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Picked v10.2.1

Development

Successfully merging this pull request may close these issues.

5 participants