Get signtool
signtool is part of the Windows SDK. Install the SDK and tick “Windows SDK Signing Tools for Desktop Apps”. It is usually not on your PATH: typing signtool in PowerShell answers that the name is not recognised. Either open “Developer PowerShell for VS” from the Start menu, which knows it, or call it by its full path. The folder carries the SDK’s version number, so list yours first:
/a below picks the best one. Without a certificate signtool says that no certificates were found. When Bach signs for you (see below), it finds signtool in the SDK folder by itself.
Sign after you build
1
Build
2
Sign the finished file
3
Verify
4
Write the update feed again
Only if you use
[updates]. Signing changes the file’s SHA-256.Let Bach sign (optional)
Signing is never required. If you would rather not run the signing tool yourself, add[signing] to bach.toml and build with --sign:
bach.toml
signtool the arguments start with the word sign. Bach refuses them otherwise, because signtool answers “Invalid command”. Bach then signs every setup file it writes (the offline installer, the online installer and an update patch) before it writes the update feed, so the feed already carries the signed file’s SHA-256. Keep secrets out of bach.toml with {env:NAME} in the arguments. Bach prints the command first and fails the build when the signer fails.
bach sign FILE signs a file you built earlier in the same way. See bach sign.
Notes
- Sign after
bach build, never before. Building writes into the file. With--sign, Bach does it in that order for you. - The uninstaller is unsigned. The
uninstall.exean install leaves behind is written on the user’s computer from the signed setup file, without the signature, because a signature only covers the exact file it was made for. - Signing the setup file does not sign the programs inside it. Windows 11’s Smart App Control looks at every program that starts, so sign your own
.exeand.dllfiles in your build, before Bach packs them. With[signing]inbach.toml,bach checkandbach buildwarn when packed programs or libraries have no signature, and name the first three. Bach only reads the file’s signature entry; Windows still decides whether it is valid. Without[signing]there is no warning, because you may not sign at all. bach inspectreads signed setup files too.bach doctorreports whether the Windows SDK’ssigntoolis found (on other systemsosslsigncode; a program that only happens to be calledsigntool, like Mozilla’s NSS tool on Linux, is not taken for it), or that[signing]is set. Signing is optional.
Why signing works
The payload sits before the signature’s certificate table, sosigntool signs a setup file like any other program and the signature covers the payload. See How Bach works.
Check a Bach download
Every file of a Bach release (the zip,bach-setup.exe, the example installer, the macOS and Linux downloads and the Windows ARM64 zip) has a signed statement from GitHub’s artifact attestations: which commit and which workflow run built it. With the GitHub CLI:
bach and bach-setup.exe are built from, as CycloneDX files: bach-<version>-sbom-cli.cdx.json and bach-<version>-sbom-setup.cdx.json. Each lists every crate with its version, licence and the checksum from Cargo.lock. The runtime’s list is attached to bach-setup.exe as an attestation too. The .sha256 files remain.
Next steps
Updates
Publish the signed file and the feed.
winget
List the signed file in the Windows Package Manager.