← Back to Pull requests

Reload rotated client certificates in the TLS check #25363

Open
unknown opened this pull request with 373 lines diff across 4 files
View on GitHub
unknown unknown commented on Sep 27, 2026 01:49 UTC
Author

What does this PR do?

Reload the TLS integration's SSL context before each remote certificate check so rotated client certificates and keys take effect without restarting the Agent. Strictly load configured client credentials before the handshake: missing, unreadable, malformed, or mismatched files produce CRITICAL tls.validation and no certificate-age metrics, with automatic recovery when valid credentials are available.

Preserve downloaded intermediate CA certificates across refreshes only while their originating URI cache entries remain valid. Expired entries leave both the cache and refreshed trust store, including when discovery or refetching fails. Continue AIA traversal through cached intermediates so expired parents can be renewed. Validate downloaded DER with OpenSSL before caching it.

Keep per-run refresh to detect replacements that preserve file timestamps, and avoid creating a second SSL context on the first use. Document the transient failure during non-atomic rotation in tls/changelog.d/25363.fixed.

Motivation

The remote TLS check caches its SSL context for the lifetime of the check instance. When a certificate manager rotates the configured client certificate and key on disk, subsequent checks continue presenting the original certificate. Once that certificate expires, the server rejects it even though valid replacement files exist.

Validation:

  • Full ddev --no-interactive test tls: 85 passed, 6 skipped. The skips are the five E2E/FIPS tests excluded from this invocation and an existing test disabled for an expired external certificate.

  • Focused rotation and intermediate-cache tests: 28 passed, using real TLS handshakes and generated certificates. Coverage includes modern and legacy configuration, combined PEM, encrypted keys, preserved timestamps, incomplete rotations, failure/recovery against a server permitting anonymous TLS, and intermediate trust expiry.

  • Seven missing-credential and expired-trust cases fail against the previous PR implementation (2d604ee1) and pass with these fixes.

  • ddev --no-interactive test --lint tls: passed.
  • QA is required; a maintainer needs to add qa/required because the author account cannot apply labels.

    QA should exercise a long-running Agent across client-certificate rotation and expiry of the original certificate, including fetch_intermediate_certs. Verify replacement credentials reach the endpoint, incomplete rotations report CRITICAL without age metrics, and monitoring recovers once the files form a valid pair.

    Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)

  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.

  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged
  • Diff: 373 lines (+279 / -94) across 4 files Reviewer: iliakur Review duration: 22559m
    All Vouch review confidence checks passed
    Residual risk 0.39 = Change Risk (0.66) × (1 − Review Confidence (0.40)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.66 · 373 lines diff across 4 files
    0.66
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    40%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.354
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.066
    Real PR Conversation Timeline
    1 comments
    "Review active on #25363"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 40.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 66% (HIGH) · Higher = larger blast radius
    66%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 40.5% · Lower = rushed or shallow review
    40.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 39.3% · Moderate risk
    39.3%