Skip to content

Fix BoringSSL dual-certificate default selection - #13712

Merged
moonchen merged 1 commit into
apache:masterfrom
moonchen:fix/boringssl-dual-cert-default
Oct 5, 2026
Merged

moonchen merged 1 commit into
apache:masterfrom
moonchen:fix/boringssl-dual-cert-default

Conversation

@moonchen

@moonchen moonchen commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

With BoringSSL, a default entry containing RSA and EC certificates serves only the last certificate to clients with no SNI or an unknown SNI. Clients restricted to the other key type fail with handshake_failure, despite a compatible certificate being configured.

After name and address lookups miss, select the existing * entry for the client’s key type. This reuses the entries maintained by certificate loading and secret updates; OpenSSL’s native dual-certificate selection is unchanged. A default action: tunnel entry on a transparent port also applies to these fallback clients.

Add regression coverage for both certificate orders, RSA and ECDSA clients, TLS 1.2 and TLS 1.3, and absent, unknown, and matching SNI. The original callback fails the regression with alert 40; the fix passes it with BoringSSL and preserves OpenSSL behavior.

Fixes: #13793

Clients without a matching SNI can reject a dual-certificate default
when its last certificate has an incompatible key type. Select the
existing typed star entry after name and address misses, leaving native
dual-certificate selection unchanged and testing both orders with TLS
1.2 and TLS 1.3. This also honors a default tunnel action for
transparent connections.
Copilot AI lite review requested due to automatic review settings September 22, 2026 18:09

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Adds regression coverage and a fallback certificate-context selection path to ensure BoringSSL serves an RSA or ECDSA default certificate that matches the client’s constrained signature algorithms when SNI lookup misses.

Changes:

  • Add a gold test that probes default vs named certificate selection across TLS 1.2/1.3, RSA/ECDSA, and multiple SNI scenarios using openssl s_client -sigalgs.
  • Add two replay definitions to exercise dual-certificate default selection with both RSA→EC and EC→RSA certificate ordering.
  • Update TLSCertSwitchSupport::selectCertificate to fall back to the stored * context for the requested key type when name and destination lookups miss.
File Description
tests/​gold_tests/​tls/​tls_dual_cert_default_client.py New helper client that validates selected cert/key type under restricted signature algorithms.
tests/​gold_tests/​tls/​tls_dual_cert_default.test.py New gold test wiring replay + helper client validation for both cert orders.
tests/​gold_tests/​tls/​replay/​dual_cert_default_rsa_ec.replay.yaml Replay covering RSA-first dual-cert default configuration.
tests/​gold_tests/​tls/​replay/​dual_cert_default_ec_rsa.replay.yaml Replay covering EC-first dual-cert default configuration.
src/​iocore/​net/​TLSCertSwitchSupport.cc Adds wildcard (*) fallback selection by key type when other lookups miss.

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

@moonchen

Copy link
Copy Markdown
Contributor Author

[approve ci autest 2]

@moonchen

Copy link
Copy Markdown
Contributor Author

[approve ci autest 2]

@bryancall bryancall added this to the 11.0.0 milestone Sep 28, 2026
@bryancall
bryancall self-requested a review September 28, 2026 22:32

@bryancall bryancall 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.

✅ Approve

I reviewed 5168392148: one commit, 5 files, +228/-4. CI is 14 of 14 green. The fix is right and narrowly scoped. With BoringSSL, a dest_ip: "*" entry holding an RSA and an EC certificate becomes one context per key type, and each calls setDefaultContext (SSLUtils.cc:1778-1783), so the default is whichever is listed last. A client with no SNI or an unknown SNI misses the name lookup, misses the address lookup because * is stored as a name and not an address, and used to stay on that default. The new fallback at TLSCertSwitchSupport.cc:95-97 picks the stored * context for the client's key type. It only runs when ctxType != GENERIC, which happens only without HAVE_NATIVE_DUAL_CERT_SUPPORT (SSLUtils.cc:276-282), so OpenSSL is untouched.

Verified: the fix works on BoringSSL, on Linux and macOS

I built ATS against BoringSSL on two systems and ran tls_dual_cert_default three ways: at this head, with TLSCertSwitchSupport.cc reverted to the base, and with the fix put back.

  • Linux: a Fedora 44 x86_64 host, building in the CI image ci.trafficserver.apache.org/ats/fedora:44 against its /opt/h3-tools-boringssl/boringssl, the same BoringSSL the quiche-on-BoringSSL job uses. The client was OpenSSL 3.5.7.
  • macOS: macOS 27.0 on Apple silicon with Apple clang, against BoringSSL c3ffc3300 (the commit tools/build_boringssl_h3_tools.sh pins), built from source. The client was OpenSSL 3.6.4.

On both, the running traffic_server loads BoringSSL's libssl and libcrypto and no other, HAVE_NATIVE_DUAL_CERT_SUPPORT is undefined, and the test isn't skipped. The results matched:

  • At this head: passes, with 12 of 12 selections in each certificate order.
  • Fix reverted: fails. The rsa_ec run stops at its first case, an RSA-only TLS 1.2 client with no SNI, with SSL alert number 40, and the ec_rsa order fails the same way on its first ECDSA case. Running every case on Linux shows 8 of 12 passing in each order: a client that supports only the first-listed key type gets alert 40 with no SNI or an unknown SNI, on TLS 1.2 and 1.3, while one.com still works.
  • Fix put back: passes again.

Verified: the test checks the key type, not only the certificate name

Both default certificates carry CN foo.com, so the CN check alone can't tell RSA from EC. The helper pins exactly one signature algorithm (tls_dual_cert_default_client.py:36-37), pins an ECDHE-RSA or ECDHE-ECDSA cipher on TLS 1.2 (:40-42), and asserts the Signature type (:46). The pinned cipher matters: without it, the TLS 1.2 capability check in BoringSSLUtils.cc would see ECDSA suites in the default list and treat an RSA-only client as EC-capable. Running both certificate orders covers both directions, and the one.com cases are a control that takes the name path. I ran the helper against stand-in openssl s_server instances with the repo's certificates: an EC-only server fails the first RSA case with alert 40, an RSA-only server fails the first ECDSA case, and a dual-certificate server passes. A failure exits nonzero, which fails the chained command and the PASS: 12 check. Your replies to Copilot hold: -brief prints Signature type: (3.6.4 prints rsa_pss_rsae_sha256, older versions RSA-PSS, and the pattern takes both), and the timeout is per handshake.

Non-blocking: CI doesn't run this fix

The AuTest job builds ci-fedora-autest, which is OpenSSL. There ctxType is always GENERIC, so the new fallback never runs and the test passes with or without the fix. The Rocky BoringSSL job runs only ctest, so the first automated run that exercises this is the post-merge quiche-on-BoringSSL AuTest. When the rsa_ec run fails, autest skips ec_rsa, so a regression would show only one order; Test.ContinueOnFail = True would report both.

Non-blocking: the * fallback goes through the tunnel check

The fallback calls SSLNetVConnection::_lookupContextByName, which blind-tunnels a transparent connection when the entry has action: tunnel (SSLNetVConnection.cc:2031-2034). Your description says this is intended, and it only changes a config that didn't work before: a * tunnel entry has no certificate, so unmatched clients used to fail the handshake on both libraries. Now, on BoringSSL transparent ports only, they're tunneled, while OpenSSL still fails them. Worth a sentence under action: tunnel in ssl_multicert.yaml.en.rst:132-134, or a test, so the difference isn't discovered in production.

Relatedly, when the SNI lookup has already decided to tunnel, _lookupContextByName returns null and marks the connection TRANSPORT_BLIND_TUNNEL. _lookupContextByIP() checks for that and returns null, but the new fallback doesn't, so it calls SSL_set_SSL_CTX on a connection that's already a tunnel. I don't see harm since the handshake is marked done, but the same guard _lookupContextByIP() uses would keep the three lookups consistent.

Non-blocking: follow-ups

  • Address-bound dual certificates have the same bug. SSLCertLookup::find(const IpEndpoint &) tries EC first and ignores the client's key type (SSLCertLookup.cc:301-311). A dual-certificate dest_ip: 127.0.0.1 entry still gives an RSA-only client the EC context on BoringSSL, and because the address lookup succeeds, the new fallback never runs. That's outside this PR's scope, so an issue is enough.
  • Logging. The debug line at TLSCertSwitchSupport.cc:107 says "found" for a name, address or * match alike. A Dbg naming the key type when the fallback fires would make this visible in a trace.
  • dest_ip: "" in both replay files is the same as leaving it out. Leading that entry with ssl_cert_name would read less like it means something.
  • HasOpenSSLVersion('1.1.1') checks the library ATS links, not the openssl the helper runs. That matches other tests.

@moonchen

moonchen commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for verifying on both platforms. I filed #13793 for address-bound dual certificates. A follow-up PR will add the blind-tunnel guard to the fallback, the action: tunnel doc sentence, Test.ContinueOnFail, a Dbg line when the fallback runs, and drop the empty dest_ip from the replay files.

@moonchen
moonchen merged commit 1d7ff6e into apache:master Oct 5, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BoringSSL: dual certificates bound to an address ignore the client's key type

3 participants