Skip to content

tls: handle windows certstore refresh - #12824

Merged
edsiper merged 4 commits into
masterfrom
cosmo0920-handle-windows-certstore-refresh
Nov 20, 2026
Merged

edsiper merged 4 commits into
masterfrom
cosmo0920-handle-windows-certstore-refresh

Conversation

@cosmo0920

@cosmo0920 cosmo0920 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Moved the Windows certificate-chain lookup off the handshake thread and limited it to one lookup per TLS context per minute, with at most one lookup in flight. Windows receives the full peer chain, including cross-signed certificates in either order. OpenSSL retains its original verification result and error queue. TLS implementation: src/tls/openssl.c:690

The first handshake still fails when its root is missing. A later connection reloads the configured store and can succeed. Outputs need retries enabled to preserve that first batch. The refresh also applies to server-side client-certificate verification. New connections pick up removed roots and exclude anchors listed in the Windows Disallowed store. FLB_WINDOWS_AUTO_ROOT_UPDATE=off disables background lookups. Windows TLS documentation: docs/windows-tls.md

Verified the cold-store recovery against DigiCert’s ECC G5 endpoint. The first connection failed and scheduled one lookup. Windows installed the previously absent root in LocalMachine\AuthRoot, and the next five verified connections succeeded.

On Windows x64, both focused CTest suites and 13 integration cases passed. Coverage includes buffered delivery after issuer import, rejection after issuer removal, repeated failed handshakes with one lookup, cross-signed chain order, mutual TLS, and the opt-out. The deterministic store tests are now in the Windows x64 CI workflow. CI workflow: .github/workflows/call-windows-unit-tests.yaml:283

ctest --test-dir build-codex-otel -R '^(flb-it-upstream_tls|flb-rt-out_http)$' --output-on-failure

$env:FLUENT_BIT_BINARY = (Resolve-Path build-codex-otel/bin/fluent-bit.exe).Path
& tests/integration/.venv/Scripts/python.exe -m pytest -q tests/integration/scenarios/tls `
  tests/integration/scenarios/out_http/tests/test_out_http_001.py -k 'tls or windows_certstore'
& tests/integration/.venv/Scripts/python.exe -m pytest -q --tb=short `
  tests/integration/scenarios/tls/tests/test_windows_root_update.py -k client_certificate

The two opt-in public download cases skipped on rerun because their roots were already installed.

Closes #12818.


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • New Features
    • Windows TLS connections can use certificates from the system store, including for datagram connections.
    • When certificate verification fails because an issuer is missing or self-signed, Windows can look up the peer’s certificate chain and retry verification. Automatic root updates are enabled by default and can be disabled.
  • Documentation
    • Added guidance on Windows certificate verification, root lookups, retry behavior, logging, and configuration.

Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T10:11:29.566590Z f0d35a4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Windows TLS contexts now support background peer-chain lookups and filter system certificates against the Disallowed store. The change also updates TLS integration tests, the Windows test workflow, and Windows TLS documentation.

Changes: Windows TLS Root Updates

Layer / File(s) Summary
Configure Windows system certificates
src/tls/flb_tls.c, src/tls/openssl.c
Windows client contexts mark system-certificate use for stream and datagram modes. Context creation and reload control default-CA loading. Session creation returns an error on a failed reload when system certificates are active and no CA file or path is configured.
Resolve peer chains and filter certificates
src/tls/openssl.c
Windows verification can schedule a background peer-chain lookup, limited to one active worker and one scheduling attempt per 60 seconds. System-certificate import skips certificates found in the Disallowed store. Session creation collects completed workers, and context destruction waits for active workers.
Test and document Windows certificate behavior
tests/integration/scenarios/out_http/tests/test_out_http_001.py, tests/integration/scenarios/tls/tests/test_windows_root_update.py, .github/workflows/call-windows-unit-tests.yaml, docs/windows-tls.md
Integration tests cover certificate-store states, chain ordering, lookup scheduling, and optional root downloads. The Windows workflow runs the tests, and the documentation describes root lookup behavior and test setup.

Estimated code review effort: 4 (Complex) | ~50 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant FluentBitTLS
  participant OpenSSLVerifyCallback
  participant WindowsChainLookupWorker
  participant WindowsChainAPI
  FluentBitTLS->>OpenSSLVerifyCallback: Verify peer certificate
  OpenSSLVerifyCallback->>WindowsChainLookupWorker: Schedule eligible chain lookup
  WindowsChainLookupWorker->>WindowsChainAPI: Evaluate peer chain with AIA disabled
  WindowsChainAPI-->>WindowsChainLookupWorker: Return chain result
  WindowsChainLookupWorker-->>FluentBitTLS: Record worker result
Loading
Merge Risk: Minimal · up to f0d35

This change moves Windows certificate-chain lookup into a throttled background worker so later connections can pick up newly installed roots. No actionable merge-blocking risk remains. The first handshake still fails when its root is missing, as the PR documents.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "tls: handle windows certstore refresh" matches the main change. The PR adds a Windows certificate-store refresh path that runs background root lookups after verification fails for missing o…
Linked Issues check Passed [#12818] The issue asks that Fluent Bit let Windows resolve a missing root, either by triggering chain construction and reloading the store (with retry), or by verifying through Windows APIs. The PR i…
Out of Scope Changes check Passed The changes stay within Windows root-trust handling for TLS. Changes: src/tls/openssl.c adds the background lookup, rate limit (one per context per 60 seconds, one in flight), the FLB_WINDOWS_AUTO_ROO…
Full details: Title check

Explanation

The title "tls: handle windows certstore refresh" matches the main change. The PR adds a Windows certificate-store refresh path that runs background root lookups after verification fails for missing or self-signed issuers, reloads the store on new connections, and filters the Windows Disallowed store. The title names the TLS area and the certstore refresh. It is concise and specific. It does not name the background lookup, but that detail is not required in a short title.

Full details: Linked Issues check

Explanation

[#12818] The issue asks that Fluent Bit let Windows resolve a missing root, either by triggering chain construction and reloading the store (with retry), or by verifying through Windows APIs. The PR implements the first approach. On a missing or self-signed issuer failure, src/tls/openssl.c schedules an asynchronous peer-chain lookup through Windows. The lookup imports the peer chain into a temporary store and records the result. Later TLS contexts reload the configured store, so a root installed in LocalMachine\AuthRoot is trusted on a later connection. The issue reports this later-attempt recovery as the observed pattern ("Fluent Bit succeeds on its next attempt"). Integration tests cover buffered delivery after issuer import, rejection after issuer removal, and repeated failed handshakes with one lookup. Limitation: the first handshake still fails and does not retry in the same call. The PR documents this and states that outputs need retries enabled. This gap is a known scope limit, not an unimplemented requirement. Evidence is from the change summary and PR description; the source lines were not re-read in this assessment.

Full details: Out of Scope Changes check

Explanation

The changes stay within Windows root-trust handling for TLS. Changes: src/tls/openssl.c adds the background lookup, rate limit (one per context per 60 seconds, one in flight), the FLB_WINDOWS_AUTO_ROOT_UPDATE opt-out, Disallowed-store filtering, and the client-certificate refresh path. src/tls/flb_tls.c adds Windows system-certificate initialization and a reload-result check during session creation. Tests and CI cover these behaviors. docs/windows-tls.md documents them. The PR description names each of these behaviors. The Disallowed-store exclusion and server-side client-certificate refresh go beyond the literal issue text, but they apply the same root-trust refresh to the same store. The macOS initialization path is kept unchanged. Excluded PEM fixtures (tests/integration/scenarios/out_http/certificate/*.pem) were not inspected; they are test inputs only and do not change the assessment.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7296b155-bc4e-4b25-ba96-fccacc0b28f8
Commits

Reviewing files that changed from the base of the PR and between c3a31b8 and f0d35a4.

Files ignored due to path filters: 2

  • tests/integration/scenarios/out_http/certificate/certstore_cross_signed.pem is excluded by !**/*.pem
  • tests/integration/scenarios/out_http/certificate/certstore_server.pem is excluded by !**/*.pem
Files selected for processing: 6

  • .github/workflows/call-windows-unit-tests.yaml
  • docs/windows-tls.md
  • src/tls/flb_tls.c
  • src/tls/openssl.c
  • tests/integration/scenarios/out_http/tests/test_out_http_001.py
  • tests/integration/scenarios/tls/tests/test_windows_root_update.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@edsiper
edsiper merged commit 1892277 into master Nov 20, 2026
72 of 73 checks passed
@edsiper
edsiper deleted the cosmo0920-handle-windows-certstore-refresh branch November 20, 2026 19:56

This branch had an error being deployed

1 failed deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: TLS verify fails when the server's root CA is not yet in the local store (Windows automatic root update is never triggered)

2 participants