fix(cargo-wdk): remove network dependency from automatic test signing - #725
fix(cargo-wdk): remove network dependency from automatic test signing#725Shravan Vasista (svasista-ms) wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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.comfrom test signing and switchsigntoolto select the cert via/sha1 <thumbprint>. - Add store-certificate discovery/selection based on EKU + expiry margin, with parsing of
certmgr -v -soutput 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.
| /// 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. |
| 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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
signtool signhard-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
WDRTestCertStorelisting, reused only when they carry the code-signing EKU and have 90+ days of validity remaining. OtherwiseWDRLocalTestCertis created withmakecert. 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.cerin the target directory, which previously short-circuited the check and masked an expired or deleted store certificate.Fixes #631