Skip to content
Open
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
bdbbe77
feat: test signing customization
svasista-ms Jul 7, 2026
4d0063f
Refactor build signing options to use `--signtool-args` for certifica…
svasista-ms Jul 7, 2026
9753ca4
test: move functional tests for `--signtool-args` passthrough into a …
svasista-ms Jul 7, 2026
6099a73
refactor: improve staging and final package directory handling in pac…
svasista-ms Jul 8, 2026
3f7206b
feat: enhance signtool argument handling and improve security warnings
svasista-ms Jul 12, 2026
dcadac9
feat: enhance signtool argument handling and improve parsing logic
svasista-ms Jul 12, 2026
b66c678
refactor: remove staging paths in packaging process
svasista-ms Jul 14, 2026
653627a
test: add tests for handling empty signtool args and sign mode valida…
svasista-ms Jul 15, 2026
936780f
refactor: move build command args tests into a separate module
svasista-ms Jul 15, 2026
3922c47
test: remove outdated comments from signtool failure test
svasista-ms Jul 15, 2026
e21e4c3
fix: correct formatting of extra file operand in signtool args
svasista-ms Jul 15, 2026
872ddf4
refactor: update help heading for driver signing and verification opt…
svasista-ms Jul 15, 2026
1e23e88
fix: handle empty signtool arguments in parse_signtool_args function
svasista-ms Jul 15, 2026
3e87ce0
docs: fix driver signing options section
svasista-ms Jul 15, 2026
82ab302
Merge branch 'main' into test-signing
svasista-ms Jul 21, 2026
623db92
address review comments
svasista-ms Jul 21, 2026
5ef9b00
refactor: remove `hide_args` parameter and implement `run_with_redact…
svasista-ms Jul 21, 2026
10dcc64
Merge branch 'test-signing' of https://github.com/svasista-ms/windows…
svasista-ms Jul 21, 2026
74343c7
address review comments: file-scoped signtool sign error, escape sing…
svasista-ms Jul 22, 2026
101282b
Merge remote-tracking branch 'upstream/main' into test-signing
svasista-ms Jul 22, 2026
c4182d4
test(cargo-wdk): restore `TargetPlatform::as_infverif_flag` mapping test
svasista-ms Jul 22, 2026
6ac3f53
fix(cargo-wdk): redact `signtool /p` password case-insensitively
svasista-ms Jul 22, 2026
2d349fd
Merge branch 'main' into test-signing
svasista-ms Jul 27, 2026
c8fcabe
fix(cargo-wdk): restore default signtool timestamp countersignature
svasista-ms Jul 27, 2026
fcbc786
refactor(cargo-wdk): move default signtool switches into `sign_and_ve…
svasista-ms Jul 29, 2026
de3cfdf
fix(exec): add comment for lifetime requirement in `run_with_redaction`
svasista-ms Jul 29, 2026
77a3e71
refactor(cargo-wdk): replace `SignMode TryFrom` with `BuildArgs::get_…
svasista-ms Jul 29, 2026
2eed294
docs(cargo-wdk): edit `--signtool-args` note
svasista-ms Jul 29, 2026
f2a8986
docs(cargo-wdk): remove extra `signtool` related documentation
svasista-ms Jul 30, 2026
5a0bb10
fix: ensure file operand is not redacted when password is missing
svasista-ms Jul 30, 2026
2fbf359
refactor: rename `get_sign_mode` to `sign_mode`
svasista-ms Jul 30, 2026
bc7fc65
refactor(cargo-wdk): move action types into the modules that own them
svasista-ms Jul 31, 2026
70ad2b7
refactor(cargo-wdk): address review feedback on signtool signing
svasista-ms Jul 31, 2026
87ef974
test(cargo-wdk): assert package dir recreation ordering via mockall S…
svasista-ms Jul 31, 2026
8139c0c
test(cargo-wdk): simplify extra-operand signing test to a single build
svasista-ms Jul 31, 2026
8f07bf8
Merge branch 'main' into test-signing
svasista-ms Aug 4, 2026
9d8013f
docs(cargo-wdk): clarify signtool arguments description in README and…
svasista-ms Aug 4, 2026
3474cba
fix(cargo-wdk): preserve clap validation error
svasista-ms Aug 5, 2026
332a9b4
fix(cargo-wdk): preserve quoted empty signtool arguments
svasista-ms Aug 5, 2026
2a2b749
fix: stop timestamping for default test signing scenario
svasista-ms Aug 6, 2026
a306e34
Merge branch 'main' into test-signing
svasista-ms Aug 6, 2026
88f380d
Revert "fix: stop timestamping for default test signing scenario"
svasista-ms Aug 11, 2026
4bc24f4
Revert "fix(cargo-wdk): preserve clap validation error"
svasista-ms Aug 11, 2026
a0a868f
Merge branch 'main' into test-signing
svasista-ms Aug 11, 2026
d58cfaa
test: improve error assertions for signtool failures
svasista-ms Aug 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions crates/cargo-wdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,28 @@ The last component of `PATH` is used as the name of the crate.
Usage: cargo wdk build [OPTIONS]

Options:
--profile <PROFILE> Build artifacts with the specified profile
--target-arch <TARGET_ARCH> Build for the target architecture
--profile <PROFILE>
Build artifacts with the specified profile
--target-arch <TARGET_ARCH>
Build for the target architecture
--target-platform <TARGET_PLATFORM>
Driver target platform [default: universal] [possible values: desktop, universal, windows]
--sample Build sample class driver project
--sign-mode <SIGN_MODE> Driver signing mode [default: test] [possible values: off, test]
--verify-signature Verify the signature
--locked Assert that `Cargo.lock` will remain unchanged
-h, --help Print help
Driver target platform [default: universal] [possible values: universal, desktop, windows]
--sample
Build sample class driver project
--locked
Assert that `Cargo.lock` will remain unchanged
-h, --help
Print help (see more with '--help')

Driver Signing:
--sign-mode <SIGN_MODE> Signing mode [default: test] [possible values: off, test]
--signtool-args <ARGS> Custom arguments to pass to `signtool sign` when signing the driver binary and the catalog file, e.g. `--signtool-args '/fd SHA512 /n "CN=WDRLocalTestCert, O=Foo"'`
--verify-signature Verify the signatures of the driver binary and catalog file after signing

Comment on lines +79 to +83
Feature Selection:
--all-features Activate all available features
--no-default-features Do not activate the `default` feature
-F, --features <FEATURES> Space-separated list of features to activate
--all-features Activate all available features
--no-default-features Do not activate the `default` feature
-F, --features <FEATURES> Space-separated list of features to activate

Verbosity:
-v, --verbose... Increase logging verbosity
Expand Down Expand Up @@ -108,6 +116,15 @@ If the `--verify-signature` flag is provided, the signatures are verified after

`--verify-signature` cannot be combined with `--sign-mode=off` because if signing is off there is nothing to verify. Passing both will cause `build` to fail with an error.

##### Customizing signtool arguments

To sign with your own certificate or tweak any signing option, pass `--signtool-args` with a string of the arguments to forward to `signtool sign`.

- When `--signtool-args` is **omitted**, cargo-wdk signs with the auto-generated WDR test certificate as described above.
- When `--signtool-args` is **provided**, you own the full `signtool sign` option set (certificate selection, digest algorithm, etc.). `cargo-wdk` will prepend the `sign` verb to your arguments and append the trailing file operand so you should not provide them.

`--signtool-args` applies only when signing is enabled; supplying it with `--sign-mode=off` is an error.
Comment thread
svasista-ms marked this conversation as resolved.

#### Examples

- To build a driver project with default options, navigate to the root of the project and run:
Expand Down
10 changes: 3 additions & 7 deletions crates/cargo-wdk/src/actions/build/build_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@ use mockall_double::double;
use tracing::debug;
use wdk_build::CpuArchitecture;

use super::features_to_cargo_args;
use super::{Profile, error::BuildTaskError, features_to_cargo_args, to_target_triple};
#[double]
use crate::providers::exec::CommandExec;
use crate::{
actions::{Profile, build::error::BuildTaskError, to_target_triple},
providers::error::CommandError,
trace,
};
use crate::{providers::error::CommandError, trace};

/// Parameters for constructing a [`BuildTask`].
pub struct BuildTaskParams<'a> {
Expand Down Expand Up @@ -156,7 +152,7 @@ mod tests {

use super::*;
use crate::{
actions::Profile,
actions::build::Profile,
providers::{error::CommandError, exec::MockCommandExec},
};

Expand Down
8 changes: 6 additions & 2 deletions crates/cargo-wdk/src/actions/build/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ pub enum PackageTaskError {
CertGenerationInStoreCommand(#[source] CommandError),
#[error("Error while acquiring mutex for generating certificate. HRESULT: {0:#x}")]
CertMutexError(i32),
#[error("Error signing driver binary using signtool")]
DriverBinarySignCommand(#[source] CommandError),
#[error("Error signing {} using signtool", .file.display())]
SigntoolSignCommand {
file: PathBuf,
#[source]
source: CommandError,
},
#[error("Error verifying signed driver binary using signtool")]
DriverBinarySignVerificationCommand(#[source] CommandError),
#[error("Error verifying inf file using infverif")]
Expand Down
47 changes: 44 additions & 3 deletions crates/cargo-wdk/src/actions/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ mod package_task;
#[cfg(test)]
mod tests;
use std::{
fmt::{self, Display},
path::{Path, PathBuf, absolute},
result::Result::Ok,
str::FromStr,
};

use anyhow::Result;
Expand All @@ -31,10 +33,49 @@ use wdk_build::{
metadata::{TryFromCargoMetadataError, Wdk},
};

use crate::actions::Profile;
#[double]
use crate::providers::{exec::CommandExec, fs::Fs, metadata::Metadata, wdk_build::WdkBuild};

/// `x86_64/Amd64` target triple name
const X86_64_TARGET_TRIPLE_NAME: &str = "x86_64-pc-windows-msvc";
/// `aarch64/Arm64` target triple name
const AARCH64_TARGET_TRIPLE_NAME: &str = "aarch64-pc-windows-msvc";

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Profile {
Dev,
Release,
}
impl FromStr for Profile {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"dev" => Ok(Self::Dev),
"release" => Ok(Self::Release),
_ => Err(format!("'{s}' is not a valid profile")),
}
}
}
impl Display for Profile {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
Self::Dev => "dev",
Self::Release => "release",
};
write!(f, "{s}")
}
}

/// Converts `CpuArchitecture` to its corresponding target triple name.
#[must_use]
pub fn to_target_triple(cpu_arch: CpuArchitecture) -> String {
match cpu_arch {
CpuArchitecture::Amd64 => X86_64_TARGET_TRIPLE_NAME.to_string(),
CpuArchitecture::Arm64 => AARCH64_TARGET_TRIPLE_NAME.to_string(),
}
}

pub struct BuildActionParams<'a> {
pub working_dir: &'a Path,
pub profile: Option<&'a Profile>,
Expand Down Expand Up @@ -101,7 +142,7 @@ impl<'a> BuildAction<'a> {
working_dir: absolute(params.working_dir)?,
profile: params.profile,
target_arch: params.target_arch,
sign_mode: params.sign_mode,
sign_mode: params.sign_mode.clone(),
is_sample_class: params.is_sample_class,
locked: params.locked,
target_platform: params.target_platform,
Expand Down Expand Up @@ -407,7 +448,7 @@ impl<'a> BuildAction<'a> {
working_dir,
target_dir: &target_dir,
target_arch: &target_arch,
sign_mode: self.sign_mode,
sign_mode: self.sign_mode.clone(),
sample_class: self.is_sample_class,
driver_model,
target_platform: self.target_platform,
Expand Down
Loading
Loading