Skip to main content
When someone downloads and runs an unsigned installer, Windows may show Windows protected your PC and call the publisher unknown. Code signing attaches your identity to the file. This page explains what you need and how to sign with Bach.

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’s signtool 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. Add a [signing] section that says how your certificate is found:
bach.toml
/a lets signtool pick the best certificate. Then build with --sign:
Bach signs every setup file it writes, including an online installer or update patch, before it writes the update feed. If signing fails, the build fails. Bach finds signtool in the Windows SDK by itself. A few details:
  • Signing only runs when you ask, with --sign or the environment variable BACH_SIGN=1. A bach.toml from someone else could name any program, so Bach never runs it just because you built.
  • For signtool, arguments must start with sign.
  • Use program for 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 after bach build, never before, because building writes into the file:
If your app uses [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

The uninstall.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 your bach.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
With 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:
Each release also lists the libraries in bach and bach-setup.exe as CycloneDX files.