Skip to content

fix(cargo-wdk): remove network dependency from automatic test signing - #725

Draft
Shravan Vasista (svasista-ms) wants to merge 1 commit into
microsoft:mainfrom
svasista-ms:fix/631-offline-test-signing
Draft

fix(cargo-wdk): remove network dependency from automatic test signing#725
Shravan Vasista (svasista-ms) wants to merge 1 commit into
microsoft:mainfrom
svasista-ms:fix/631-offline-test-signing

Conversation

@svasista-ms

Copy link
Copy Markdown
Contributor

signtool sign hard-coded /t http://timestamp.digicert.com, so packaging a driver failed on machines without internet access. Test signatures are trusted only while the signing certificate is valid, so timestamping them adds little value.

In this PR, the timestamp switch is dropped during test signing and the certificate used in the automated test signing flow is selected by its SHA-1 thumbprint and validity rather than subject name alone. Certificates are now chosen from the WDRTestCertStore listing, reused only when they carry the code-signing EKU and have 90+ days of validity remaining. Otherwise WDRLocalTestCert is created with makecert. A named mutex serializes store access so concurrent builds do not race to create duplicate certificates.

This also removes the early return on an existing WDRLocalTestCert.cer in the target directory, which previously short-circuited the check and masked an expired or deleted store certificate.

Fixes #631

Copilot AI lite review requested due to automatic review settings August 25, 2026 12:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates cargo-wdk’s test-signing flow to avoid requiring network access (by removing signtool sign timestamping), and hardens automatic test-certificate selection by choosing a valid code-signing cert from WDRTestCertStore via SHA-1 thumbprint + remaining validity (creating a new cert when needed, and serializing store access with a named mutex).

Changes:

  • Remove /t http://timestamp.digicert.com from test signing and switch signtool to select the cert via /sha1 <thumbprint>.
  • Add store-certificate discovery/selection based on EKU + expiry margin, with parsing of certmgr -v -s output and unit tests for the parser.
  • Update cargo-wdk build tests to match the new cert lookup/export/signing behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
crates/cargo-wdk/src/actions/build/tests.rs Updates mocked command expectations to cover cert lookup sequences and /sha1-based signing.
crates/cargo-wdk/src/actions/build/package_task.rs Implements thumbprint-based certificate selection/export, removes timestamping, and adds certmgr output parsing + tests.
crates/cargo-wdk/src/actions/build/error.rs Adds a dedicated error for “created cert but still couldn’t find a usable one”.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +2658 to +2660
/// Mocks the `certmgr -v -s <store>` lookups. The outputs are returned in
/// order and then repeated, so a `[not found, not found, found]` sequence
/// covers one create-then-select cycle per driver.
Comment on lines +2661 to +2668
fn expect_certmgr_cert_lookup(mut self, outputs: Vec<Output>) -> Self {
let expected_certmgr_command: &'static str = "certmgr.exe";
let expected_certmgr_args: Vec<String> =
vec!["-s".to_string(), "WDRTestCertStore".to_string()];
let expected_certmgr_args: Vec<String> = vec![
"-v".to_string(),
"-s".to_string(),
"WDRTestCertStore".to_string(),
];
let mut call_index = 0usize;
@codecov-commenter

Codecov Comments Bot (codecov-commenter) commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.98678% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.83%. Comparing base (7d3000c) to head (6e437f4).

Files with missing lines Patch % Lines
crates/cargo-wdk/src/actions/build/package_task.rs 88.98% 3 Missing and 22 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #725      +/-   ##
==========================================
+ Coverage   82.64%   82.83%   +0.18%     
==========================================
  Files          25       25              
  Lines        6459     6628     +169     
  Branches     6459     6628     +169     
==========================================
+ Hits         5338     5490     +152     
+ Misses        989      988       -1     
- Partials      132      150      +18     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

wdk-build: The signtool-sign build process requires network connection for a little value

3 participants