Repository navigation
fix(telemetry): check collector certificates on https OTLP exports - #14865
Conversation
HTTPS OTLP exports from the Swoole transport now validate the collector certificate against the system CA store and the endpoint hostname. A new optional certificateAuthority argument lets internal collectors use a private CA bundle. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. No blocking issues — approved ✅; 1 nitpick below. 🧹 Nitpicks (1) — 🟢 1 low
The change extends the Swoole telemetry transport so OTLP exports can verify collector certificates against a configured CA bundle instead of silently accepting any peer, and adds integration tests exercising trusted, untrusted, and hostname-mismatch certificate scenarios against a mock OTLP server that generates its own certificates in-test. Overall the transport changes are sound and strengthen TLS verification; the issues found are confined to the test harness and configuration ergonomics.
Reviewed commit: a02282e |
🟢 Tier S · Ready to mergeThe Swoole OTLP transport validates HTTPS collector chains and DNS identities using the system CA store or an optional private CA bundle. For IP endpoints, it checks the certificate's IP SAN before exporting and pins subsequent pooled reconnects; integration coverage exercises trusted and rejected certificates, payload withholding, and reconnect behavior. Latest changes: The latest commits record HTTP methods alongside stray requests and require the IP verification probe to appear specifically as
📂 Walkthrough · 3
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Swoole 6.2 checks ssl_host_name with X509_check_host(), which matches DNS names and the subject CN but never IP subject alternative names, and it exposes no option for X509_check_ip(). A CA-trusted certificate issued for the IP an endpoint names was therefore rejected. For an https endpoint addressed by IP, Swoole now only verifies the chain, and the transport checks the peer certificate's IP SANs itself on a HEAD request that carries neither the configured headers nor a payload, before the connection carries an export. Swoole silently reconnects a pooled socket the collector dropped, which would skip that check, so a verified client is pinned to ssl_host_name = the address: such a reconnect fails closed, and the export is retried on a fresh, verified connection since nothing was sent. DNS endpoints keep Swoole's hostname verification. The hostname-mismatch test connected to 127.0.0.1 with a DNS:localhost certificate, so it exercised this limitation rather than a mismatch. It now uses a DNS endpoint with a certificate for another DNS name, and new cases cover an IP endpoint with a matching IP SAN, one with another IP SAN, a reconnect to a collector presenting another IP SAN, and a reconnect after the collector drops a pooled connection. Certificates are now issued by a test authority instead of being self-signed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The address check ran its HEAD request against the endpoint path, so a collector presenting a certificate for another address still received the endpoint's path and query before the check refused it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ss request The mock server's readiness probe also requests the root path, so asserting that something reached the root passed even without an address check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…icates fix(telemetry): check collector certificates on https OTLP exports (cherry picked from commit 8901412)
What does this PR do?
HTTPS OTLP exports from the Swoole transport now validate the collector certificate against the system CA store and the endpoint hostname. A new optional certificateAuthority argument lets internal collectors use a private CA bundle.
For endpoints addressed by IP, Swoole's hostname check only matches DNS names, so the transport verifies the certificate chain, confirms the peer certificate carries a matching IP SAN on each new connection before sending any headers or payload, and pins later reconnects of that pooled connection.
Test Plan
Unit and E2E suites for packages/telemetry, run in appwrite/base:2.2.7 (unit 26, e2e 19). TransportIntegrationTest covers an untrusted certificate, a DNS name mismatch, a trusted DNS certificate, an IP endpoint with a matching IP SAN (accepted), one with a different IP SAN (refused, nothing sent), a reconnect to a certificate naming another address (refused), and a reconnect after the collector drops a pooled connection (succeeds). MockOtlpServer can serve TLS from a test CA. bin/monorepo check telemetry (Rector, Pint, PHPStan) is clean.
Related PRs and Issues
Checklist
🤖 Generated with Claude Code