Repository navigation
Fix BoringSSL dual-certificate default selection - #13712
Conversation
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.
There was a problem hiding this comment.
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
Open (3)
A 10-second timeout can be flaky on slower/loaded CI hosts, especially since this runs multiple… · Newopenssl s_client -briefoutput commonly usesPeer signature type:(and may vary across OpenSSL… · New The test hard-codes the total case count (12), which will break if the helper’s matrix changes… · New
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::selectCertificateto 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.
|
[approve ci autest 2] |
|
[approve ci autest 2] |
bryancall
left a comment
There was a problem hiding this comment.
✅ 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:44against 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 committools/build_boringssl_h3_tools.shpins), 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_ecrun stops at its first case, an RSA-only TLS 1.2 client with no SNI, withSSL alert number 40, and theec_rsaorder 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, whileone.comstill 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-certificatedest_ip: 127.0.0.1entry 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:107says "found" for a name, address or*match alike. ADbgnaming 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 withssl_cert_namewould read less like it means something.HasOpenSSLVersion('1.1.1')checks the library ATS links, not theopensslthe helper runs. That matches other tests.
|
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 |


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 defaultaction: tunnelentry 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