Skip to content

fix(telemetry): check collector certificates on https OTLP exports - #14865

Merged
abnegate merged 4 commits into
mainfrom
fix/otlp-https-certificates
Oct 23, 2026
Merged

abnegate merged 4 commits into
mainfrom
fix/otlp-https-certificates

Conversation

@abnegate

@abnegate abnegate commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

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

  • None

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

🤖 Generated with Claude Code

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]>
@luxor-code-review

luxor-code-review Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review complete. No blocking issues — approved ✅; 1 nitpick below.

🧹 Nitpicks (1) — 🟢 1 low
  • 🟢 Remove vacuous assertNotTrue on CSR result (TransportIntegrationTest.php:156) — $this->assertNotTrue($request) after openssl_csr_new() is vacuous: that function returns an OpenSSLAsymmetricKey object or false, never true (packages/telemetry/tests/E2E/Adapter/OpenTelemetry/Swoole/TransportIntegrationTest.php:156).

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.

Files Change
packages/telemetry/src/Adapter/OpenTelemetry/Transport/Swoole.php Adds TLS settings (ssl_verify_peer, ssl_cafile, ssl_host_name) derived from a nullable certificateAuthority and endpoint host.
packages/telemetry/tests/E2E/Adapter/OpenTelemetry/Swoole/MockOtlpServer.php Extends the mock OTLP server to listen over HTTPS using generated key/certificate files.
packages/telemetry/tests/E2E/Adapter/OpenTelemetry/Swoole/TransportIntegrationTest.php New tests for trusted, untrusted, and hostname-mismatch collector certificates, plus in-test X.509 issuance via openssl_csr_new/openssl_x509_generate.

Reviewed commit: a02282e

@ghost

ghost commented Oct 23, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The 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 HEAD /, while retaining checks that no endpoint path or query reaches an unverified collector.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 3
File Change
packages/telemetry/src/Adapter/OpenTelemetry/Transport/Swoole.php Enables HTTPS peer and DNS verification, supports a custom CA bundle, and verifies IP SANs before export while preventing unchecked reconnects.
packages/telemetry/tests/E2E/Adapter/OpenTelemetry/Swoole/MockOtlpServer.php Adds TLS-serving support and records methods and URIs for requests outside the OTLP metrics path.
packages/telemetry/tests/E2E/Adapter/OpenTelemetry/Swoole/TransportIntegrationTest.php Covers certificate trust and identity checks, endpoint-data withholding, and verified pooled reconnects.

Reviewed the commits since 8dd0793 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · See the inline comments. Summary

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/otlp-https-certificates (after).

Metric Before After Change
🚀 Requests/sec 198.34 203.67 ⚪ +2.7%
⏱️ Latency P50 85.05 ms 85.1 ms ⚪ +0.1%
⏱️ Latency P95 214.69 ms 196.94 ms 🟢 -8.3%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 85.1 196.94 12,654 203.67 -17.75
Account 155.73 284.52 666 11.07 -35.11
TablesDB 81.09 152.99 6,882 112.37 -12.58
Storage 80.88 192.88 3,330 56.36 +4.08
Functions 117.91 227.17 1,776 30.82 -9.21

Top API waits (after)

API request Max wait (ms)
functions.create 513.83
account.name.update 417.69
storage.buckets.create 404.81
functions.variables.create 388.36
tokens.files.create 371.66

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]>

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · See the inline comments. Summary

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]>

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · Looks good to merge. Summary

…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]>

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@abnegate
abnegate merged commit 8901412 into main Oct 23, 2026
95 checks passed
@abnegate
abnegate deleted the fix/otlp-https-certificates branch October 23, 2026 04:04
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…icates

fix(telemetry): check collector certificates on https OTLP exports

(cherry picked from commit 8901412)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant