Skip to content

feat: introduce sign mode for driver packaging, allowing skipping of signing steps#649

Merged
gurry merged 18 commits into
microsoft:mainfrom
svasista-ms:sign-mode-off
May 27, 2026
Merged

feat: introduce sign mode for driver packaging, allowing skipping of signing steps#649
gurry merged 18 commits into
microsoft:mainfrom
svasista-ms:sign-mode-off

Conversation

@svasista-ms
Copy link
Copy Markdown
Contributor

@svasista-ms svasista-ms commented Apr 27, 2026

This PR adds a --sign-mode option to the cargo wdk build command that lets you turn off test signing which is useful for production/HLK scenarios.

Resolves #588

Functionality

--sign-mode takes two values:

  • test: generates a self-signed cert and signs artifacts with it. Same behavior as today
  • off: skips all signing including cert generation

test is the default so if --sign-mode is omitted the command behaves exactly as today and thus remains backwards compatible.

An error is returned if you try to use --verify-signature with --sign-mode=off because verification does not make sense when nothing is signed.

Future Direction

This PR is part of a broader goal to replicate Visual Studio's SignMode setting in cargo-wdk. In the future we plan to:

  • Introduce a third --sign-mode value called prod to enable a production signing mode that will not generate a test cert and will instead require a user-specified cert
  • Add CLI options for specifying certs, timestamp servers and signing algorithms

Changes

  • New sign_mode field in BuildArgs [1]
  • CLI-layer logic to reject use of --verify-signature with --sign-mode=off [2]
  • New SignMode enum with Test and Off variants [3].
  • Plumbed SignMode from BuildAction through PackageTask
  • In PackageTask::run(), gated generate_certificate, the certificate copy and signtool invocations on SignMode::Test[4]
  • Unit tests for the new paths [5]
  • Integration tests [6]

Screenshots

cargo wdk build --help showing --sign-mode:

image

Building with --sign-mode=off:

image

Building with --sign-mode=test:

image

Building without the --sign-mode option -- falls back to the default (test) behavior:

image

Error when using --verify-signature with --sign-mode=off:

image

Copilot AI review requested due to automatic review settings April 27, 2026 10:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new build-time signing mode to cargo-wdk so production packaging can skip test-signing (and associated certificate generation/verification), aligning with the request in #588 to produce unsigned driver binaries for external signing.

Changes:

  • Introduces SignMode (test default, off) and wires it through CLI → BuildActionPackageTask.
  • Updates packaging flow to conditionally skip certificate generation, signtool signing, and signature verification when --sign-mode=off.
  • Adds unit + integration tests covering --sign-mode=off, CLI validation, and help-surface expectations.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/cargo-wdk/tests/build_command_test.rs Adds integration tests for --sign-mode=off, including “not Authenticode signed” validation.
crates/cargo-wdk/src/cli.rs Adds --sign-mode flag, passes it into build params, and rejects --verify-signature with --sign-mode=off.
crates/cargo-wdk/src/actions/mod.rs Defines the SignMode enum with parsing/display behavior.
crates/cargo-wdk/src/actions/build/tests.rs Extends build action tests/mocks to cover sign-mode off behavior and propagation.
crates/cargo-wdk/src/actions/build/package_task.rs Implements sign-mode branching in packaging, skipping signing steps when off.
crates/cargo-wdk/src/actions/build/mod.rs Threads sign_mode from build action into package task params.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/cargo-wdk/tests/build_command_test.rs Outdated
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.61%. Comparing base (74b1da7) to head (d536fd8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #649      +/-   ##
==========================================
+ Coverage   79.45%   79.61%   +0.16%     
==========================================
  Files          26       26              
  Lines        5500     5544      +44     
  Branches     5500     5544      +44     
==========================================
+ Hits         4370     4414      +44     
  Misses       1001     1001              
  Partials      129      129              

☔ View full report in Codecov by Sentry.
📢 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.

svasista-ms and others added 2 commits April 27, 2026 17:27
…ification enabled

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 27, 2026 13:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/cargo-wdk/src/actions/build/package_task.rs Outdated
@svasista-ms svasista-ms marked this pull request as ready for review May 6, 2026 11:43
Copilot AI review requested due to automatic review settings May 6, 2026 11:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Comment thread crates/cargo-wdk/src/actions/mod.rs Outdated
Comment thread crates/cargo-wdk/src/actions/build/package_task.rs Outdated
Comment thread crates/cargo-wdk/src/actions/build/package_task.rs Outdated
@gurry
Copy link
Copy Markdown
Contributor

gurry commented May 7, 2026

It's odd that we're printing the error twice:
image

Why is that? Is this true for other errors as well? What can we do to fix it?

Comment thread crates/cargo-wdk/src/actions/build/tests.rs Outdated
Comment thread crates/cargo-wdk/tests/build_command_test.rs Outdated
Copilot AI review requested due to automatic review settings May 12, 2026 08:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread crates/cargo-wdk/src/actions/build/tests.rs Outdated
Comment thread crates/cargo-wdk/tests/build_command_test.rs Outdated
Comment thread crates/cargo-wdk/src/actions/build/package_task.rs
Comment thread crates/cargo-wdk/src/actions/build/tests.rs Outdated
Comment thread crates/cargo-wdk/src/actions/build/tests.rs Outdated
@gurry gurry requested a review from NateD-MSFT May 13, 2026 02:31
Comment thread crates/cargo-wdk/src/actions/mod.rs Outdated
Copilot AI review requested due to automatic review settings May 13, 2026 10:49
Comment thread crates/cargo-wdk/src/main.rs
Comment thread crates/cargo-wdk/src/actions/build/package_task.rs Outdated
Comment thread crates/cargo-wdk/src/actions/build/package_task.rs Outdated
Comment thread crates/cargo-wdk/src/actions/build/package_task.rs Outdated
Comment thread crates/cargo-wdk/README.md Outdated
Comment thread crates/cargo-wdk/README.md Outdated
Comment thread crates/cargo-wdk/README.md Outdated
Comment thread crates/cargo-wdk/README.md Outdated
Comment thread crates/cargo-wdk/README.md Outdated
Comment thread crates/cargo-wdk/README.md
Comment thread crates/cargo-wdk/src/cli.rs Outdated
Comment thread crates/cargo-wdk/src/main.rs Outdated
Comment thread crates/cargo-wdk/tests/build_command_test.rs Outdated
Comment thread crates/cargo-wdk/tests/build_command_test.rs
Comment thread crates/cargo-wdk/tests/build_command_test.rs Outdated
Comment thread crates/cargo-wdk/README.md Outdated
Comment thread crates/cargo-wdk/README.md Outdated
gurry
gurry previously approved these changes May 23, 2026
@gurry gurry enabled auto-merge May 23, 2026 10:01
@svasista-ms svasista-ms dismissed stale reviews from gurry and krishnakumar4a4 via d536fd8 May 24, 2026 11:28
@gurry gurry added this pull request to the merge queue May 27, 2026
Merged via the queue into microsoft:main with commit a90b267 May 27, 2026
323 of 325 checks passed
@gurry gurry deleted the sign-mode-off branch May 27, 2026 08:48
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.

cargo wdk build: Skip signtool

5 participants