What signing does
A code-signing certificate, bought from a certificate authority or a signing service, proves who published a file and that it hasn’t changed since. Windows then shows your name instead of “Unknown publisher”. New certificates can still get the SmartScreen warning at first, until the file or publisher has built up a reputation. You don’t need a certificate to build or test with Bach. You’ll probably want one before you share your installer widely.Get signtool
Microsoft’ssigntool comes with the Windows SDK. Install the SDK with Windows SDK Signing Tools for Desktop Apps ticked. It usually isn’t on your PATH; open Developer PowerShell for VS, or find it:
signtool.exe is in the x64 folder under the version number. Your certificate must be in the Windows certificate store, on a hardware token, or in a file you tell signtool about.
Let Bach sign (recommended)
Add a[signing] section that says how your certificate is found:
bach.toml
/a lets signtool pick the best certificate. Then build with --sign:
signtool in the Windows SDK by itself.
A few details:
- Signing only runs when you ask, with
--signor the environment variableBACH_SIGN=1. Abach.tomlfrom someone else could name any program, so Bach never runs it just because you built. - For signtool,
argumentsmust start withsign. - Use
programfor another signing tool, and{env:NAME}in the arguments for secrets, so they don’t end up in the file. See[signing]. bach sign <file>signs a file you built earlier.
Or sign yourself
Sign afterbach build, never before, because building writes into the file:
[updates], write the feed again afterwards, because signing changed the file:
Sign your programs too
Signing the setup file doesn’t sign the.exe and .dll files inside it. Windows 11’s Smart App Control checks every program that starts, so sign your own files in your build, before Bach packs them. With [signing] set, bach check warns about unsigned programs and names the first few.
The uninstaller isn’t signed
Theuninstall.exe on your users’ computers is written during install without a signature, because a signature only matches the exact file it was made for.
Require signed updates
Installed apps can refuse updates that aren’t signed by you. See Protect your updates.Sign the macOS Setup app
If yourbach.toml has a [macos] section, bach build --sign on a Mac signs the Setup app and the .dmg with Apple’s codesign. Say which certificate to use:
bach.toml
notarize, the build also sends the .dmg to Apple to be checked (notarization) and attaches the result, so the app opens without a warning. For a .pkg, set installer_identity as well. Without --sign, the app is signed “ad hoc”: it runs, but a downloaded copy asks the user to confirm the first time it opens. With [updates] signer, installed Mac apps only accept updates signed with a Developer ID Application certificate that Apple issued, with that name. Since Bach 0.11.3, bach build --sign stops if your certificate isn’t one of these, and a Mac build without --sign warns that installed copies will refuse it. Ship for macOS has the steps.
Check a Bach download
Bach’s own releases come with GitHub build attestations. To check that a download was built by Bach’s release workflow:bach and bach-setup.exe as CycloneDX files.