ssl: retain WebPKI-selected certificate chains - #8653
Conversation
Port the connection-owned chain builder from Pyre. Preserve verification inputs with TLS configurations and sessions, report the WebPKI-selected path, and publish only its selected capath anchor. Match CPython chain reporting for CERT_NONE and resumed sessions. Assisted-by: Codex:GPT-6
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Team Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe SSL backend adds full certificate-chain verification with ChangesTLS verified-chain support
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: ⚪ Minimal · up to This change records the WebPKI-selected verified TLS certificate path per connection, including accurate anchor handling and resumed-session behavior. No concrete current-head merge blocker remains. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 64.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 3 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Port the connection-owned chain builder from Pyre. Preserve verification inputs with TLS configurations and sessions, report the WebPKI-selected path, and publish only its selected capath anchor. Match CPython chain reporting for CERT_NONE and resumed sessions. Assisted-by: Codex:GPT-6
get_verified_chain()currently extends the peer's chain by matching issuer names. With two CAs sharing a subject but using different keys, it can report the wrong root and expose that certificate throughget_ca_certs()after a capath handshake. It also reads the mutable SSLContext when the chain is requested.Port Pyre's
VerifiedChainBuilderapproach: retain each connection's verification inputs, rebuild the path with WebPKI, and cache the selected leaf/intermediates/root. Publish the selected capath anchor on both client and server connections, with the certificate's actual CA classification. Keep verification inputs alongside cached configurations and explicit sessions so a declined resumption uses the same configuration that rustls verifies against. Resumed sessions report no new verified chain, matching CPython;CERT_NONEstill attempts chain construction without making failure fatal.The helper is independent of Python objects. Host I/O remains in
rustpython-host_env; path selection belongs to the TLS backend. #8648 already supplies hashed-directory filtering and connection-time loading, which this change builds on. Outgoing certificate-chain auto-completion is unchanged.Validation on macOS:
crates/capi.test_ssl: 196 tests, 43 skips. Also ran the three certificate-chain tests separately because their enclosing PHA class is skipped on rustls.CERT_NONE, mutual TLS, and accepted/declined session resumption.Implementation and validation assisted by Codex (GPT-6).
Summary by CodeRabbit