hex/docs/windows-signing.md

73 lines
3.7 KiB
Markdown

# Windows Authenticode signing
Windows releases are Authenticode-signed with Anomaly's Azure Artifact Signing
(formerly Trusted Signing) account from GitHub Actions. Signing is separate
from the ed25519 update feed: Authenticode is what Windows and SmartScreen
check, and the feed signature is what Hex's own updater checks.
## Pipeline
`.github/workflows/build-desktop.yml`, called by Release desktop with
`sign-windows: true`:
```ts
windows (x64 runner, ARM64 runner) // compiles; no credentials
└── unsigned-windows-<arch>: hex.exe + <feed>.payload.json
windows-package (one x64 runner, environment: release when signing)
├── azure/login (OIDC, no client secret)
├── artifact-signing-action: both hex.exe // SHA-256, RFC 3161 timestamp
├── build-windows-installer.ps1 x64 + arm64 // Inno embeds the signed bytes
├── artifact-signing-action: both HEX-Setup-*.exe
├── scripts/windows-authenticode.ps1 // Valid + timestamped, then re-address
│ └── signing changed the bytes -> new HEX-<v>-<sha256>-<arch>-windows.exe,
│ payload.json gets the new artifact, bytes, sha256
└── hex-windows-<arch>: payload.json, hex.exe, HEX-Setup-<v>-<x64|arm64>.exe
windows-installer (native x64, ARM64) // test-windows-installer.ps1
Release desktop sign job // ed25519-signs the feeds over the signed exe
```
- The compile jobs never hold signing credentials. Only `windows-package`
enters the `release` environment, and only when the caller sets
`sign-windows`. Test builds never set it, so they stay unsigned.
- Signing is skipped while any Azure value is missing. The run then warns
and writes "not Authenticode-signed" to its summary; everything else still
runs, including the installer tests.
- The Inno Setup uninstaller (`voice-control\uninstall\unins000.exe`) is
written at install time and is not signed. It is created locally with no
Mark of the Web, so SmartScreen does not check it.
- Self-updates download `hex.exe` through Hex itself, so SmartScreen is not
involved there either. The feed's ed25519 signature and SHA-256 protect it.
## Configuration
The workflow uses OpenCode's names. In anomalyco/hex, these are `release`
environment secrets:
- `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_SUBSCRIPTION_ID`: the Entra app
or managed identity that GitHub OIDC signs in as.
- `AZURE_TRUSTED_SIGNING_ENDPOINT`: the regional endpoint, for example
`https://eus.codesigning.azure.net/`.
- `AZURE_TRUSTED_SIGNING_ACCOUNT_NAME`, `AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE`:
the signing account and its Public Trust certificate profile.
The identity needs a federated credential with issuer
`https://token.actions.githubusercontent.com`, subject
`repo:anomalyco/hex:environment:release`, and audience
`api://AzureADTokenExchange`. It also needs the *Artifact Signing Certificate
Profile Signer* role on the profile. Luke (Hona) owns Anomaly's Azure
self-service setup.
## SmartScreen reputation
- Artifact Signing issues a short-lived certificate (about three days) for
each signing session. Without the timestamp, a signature would expire with
its certificate, so `windows-authenticode.ps1` rejects any signature that
lacks one.
- SmartScreen builds reputation per publisher identity, not per certificate.
The daily certificate rotation does not reset it. A new publisher can still
show "Windows protected your PC" on early downloads until enough installs
build reputation. The warning then names Anomaly Innovations, Inc. instead
of "Unknown publisher".
- Keep the signed bytes the same everywhere: the R2 release, the GitHub
mirror, and the installer all serve the same files. Re-signing would create
new files with no reputation.