> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Bach builds Windows installers from one bach.toml with the bach command: bach init, bach check, bach preview, bach build. Installs are per user and need no administrator rights by default. installer.scope = "machine" installs for every user after one Windows prompt. On Windows, run setup files with Start-Process -Wait -PassThru in PowerShell, and give signtool arguments that start with the word sign.

# Protect your updates

> What installed apps check before running an update, and how to add signed feeds, a required code signature, expiry dates and a new signing key.

An update runs a program on your users' computers, so it matters who can change what they download. This page explains what Bach checks by default, and the two extra protections you can turn on.

## What is always checked

* Downloads use `https` only, including redirects.
* The downloaded file must match the checksum (SHA-256) in the feed.
* It must be a setup file for the same app id, with the version the feed announced.
* It's checked again right before it runs, not only after downloading.

The weak point: the feed and the file usually live on the same host. Someone who takes over that host could replace both. Signed feeds and a required signature close this.

## Sign the update feed

You create a key pair once. The private key stays with you; the public key goes into your setup files. Installed apps then only accept feed entries signed with your private key.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
bach feed-key
```

This writes the private key to `feed-key.private` and prints the public key. It refuses to overwrite an existing file. Put the public key in `bach.toml`:

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[updates]
github = "your-name/hello-notes"
public_key = "<the 64 characters bach feed-key printed>"
```

When you build or write the feed, give Bach the private key in an environment variable:

```powershell theme={"theme":{"light":"github-light","dark":"github-dark"}}
$env:BACH_FEED_KEY_FILE = "C:\keys\feed-key.private"
bach build
```

`BACH_FEED_KEY` (the key itself) works too, for example as a CI secret. Without the key, `bach build` writes an unsigned feed and warns; `bach feed` refuses.

> [!WARNING]
>
> Keep `feed-key.private` out of Git and back it up. Apps that trust this key accept nothing else, so if you lose it, you can't send them signed updates.

On Linux and macOS the new key file is readable only by you. On Windows it has the permissions of its folder, so keep it somewhere private.

The signature covers the version, links, checksums, size, rollout and patch. Release notes aren't signed.

### Expire old feed entries

A signature proves who wrote an entry, not when. Someone who controls your host could keep serving an old, correctly signed entry, so users never see a security fix. To limit that:

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[updates]
github = "your-name/hello-notes"
public_key = "<your public key>"
max_age_days = 90
```

Installed apps then ignore entries signed more than 90 days ago. The consequence: you must sign the current release again before it gets that old, for example with a weekly scheduled workflow that runs `bach feed` and uploads `latest.json`. Otherwise your users stop getting updates.

### Change the signing key

If the key leaks or you want a new one, installed apps have to learn the new key while the old one still works:

1. Make a new key with `bach feed-key`, keeping the old one. Release a version with the old key as `public_key` and the new one as `next_public_key`. Sign that release's feed with the **old** key.
2. Wait until most users have that version. Then release with only the new key as `public_key`, and sign with the **new** key.

Users who skipped step 1 refuse the new feed and have to download the setup file again. A leaked key can't be revoked from a distance.

## Require your code signature

If you [sign your setup files](/docs/guides/signing.md), the installed app can also require that updates are signed by you:

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[updates]
github = "your-name/hello-notes"
signer = "Your Company Inc."
```

Before running a downloaded update, the app asks Windows whether the signature is valid and whether the certificate's name or organization is exactly this text. An unsigned or differently signed file is deleted and not run.

A plain name can be shared by another company. To pin yours exactly, use the certificate's whole subject. Print it from a signed file:

```powershell theme={"theme":{"light":"github-light","dark":"github-dark"}}
(Get-AuthenticodeSignature "dist\Hello-Notes-Setup-1.1.0.exe").SignerCertificate.Subject
```

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[updates]
github = "your-name/hello-notes"
signer = "CN=Your Company Inc., O=Your Company, L=Berlin, C=DE"
```

Things to keep in mind:

* Sign every file you publish, including [patches](/docs/guides/patches-and-rollouts.md). `bach build --sign` checks that the certificate matches `signer` and stops the build if not.
* The first version with `signer` has to be installed by hand, because older copies don't know the rule.
* If your certificate's name changes, you have to give users a new setup file.

The signed feed and the required signature work independently. Using both is the strongest setup.

### On a Mac

On a Mac, the same `signer` checks the Setup app inside the downloaded `.dmg` or `.zip`. It has to be signed with a Developer ID Application certificate that Apple issued, with that name. Self-signed and ad hoc signatures are refused. This needs Bach 0.11.2 or newer.

A full subject on a Mac has only two parts, such as `CN=Example Inc., OU=ABCDE12345`, where `OU` is your team id. A full subject only matches the system it was written for, so an app that ships on Windows and macOS needs the plain name, and both certificates have to carry it.

Since Bach 0.11.3, `bach build` checks this before you publish. With `--sign`, a certificate that installed Macs would refuse stops the build. Without `--sign`, the build succeeds and warns that installed copies will refuse the file. [`bach sign`](/docs/reference/cli/sign#macos-setup-files) checks a `.dmg` or `.zip` too. None of these checks ask whether the app was notarized.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.