From c59d76d721bf95cf6589a91c67a4211f45eaa350 Mon Sep 17 00:00:00 2001 From: yhirose Date: Sat, 3 Jan 2026 01:10:37 -0500 Subject: [PATCH] Add vcpkg cache cleanup step and improve Windows certificate error handling --- .github/workflows/test.yaml | 7 ++++++- httplib.h | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 135bf7b..5672480 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -142,6 +142,11 @@ jobs: script: | core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + - name: Clean vcpkg cache for different configurations + run: | + if exist "$env:VCPKG_ROOT\installed" rmdir /s /q "$env:VCPKG_ROOT\installed" + if exist "$env:VCPKG_ROOT\packages" rmdir /s /q "$env:VCPKG_ROOT\packages" + shell: pwsh - name: Setup msbuild on windows uses: microsoft/setup-msbuild@v2 - name: Install vcpkg dependencies @@ -168,4 +173,4 @@ jobs: env: VCPKG_ROOT: "C:/vcpkg" - VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + VCPKG_BINARY_SOURCES: "clear" diff --git a/httplib.h b/httplib.h index 6d31814..fcbd8c0 100644 --- a/httplib.h +++ b/httplib.h @@ -7295,7 +7295,10 @@ inline bool verify_cert_with_windows_schannel(X509 *server_cert, CERT_CHAIN_REVOCATION_ACCUMULATIVE_TIMEOUT, nullptr, &chain_context); - if (!chain_result || !chain_context) { return false; } + if (!chain_result || !chain_context) { + out_wincrypt_error = GetLastError(); + return false; + } auto chain_guard = detail::scope_exit([&] { CertFreeCertificateChain(chain_context); }); @@ -7305,6 +7308,8 @@ inline bool verify_cert_with_windows_schannel(X509 *server_cert, // Check if chain has errors if (chain_context->TrustStatus.dwErrorStatus != CERT_TRUST_NO_ERROR) { + // Set wincrypt_error to the chain trust error + out_wincrypt_error = chain_context->TrustStatus.dwErrorStatus; return false; }