Skip to content

Honor TLS handshake hook pauses on BoringSSL - #13729

Open
maskit wants to merge 1 commit into
apache:masterfrom
maskit:boringssl-handshake-hook-pause
Open

maskit wants to merge 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants