signing.adoc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. # Release signing
  2. OliveTin signs release binaries on two platforms:
  3. * **macOS** — Developer ID + notarization via [quill](https://github.com/anchore/quill) inside GoReleaser (optional only when `MACOS_SIGN_P12` is unset).
  4. * **Windows** — Authenticode via [SignPath Foundation](https://signpath.org/) in a separate GitHub Actions job (signed zip/MSI are uploaded after the release is published).
  5. ## macOS release signing
  6. Release builds can sign and notarize the `darwin` binaries using [quill](https://github.com/anchore/quill) via GoReleaser. This runs on the existing Linux CI runner; no macOS runner or Xcode is required.
  7. Signing is **optional** only when `MACOS_SIGN_P12` is unset — GoReleaser then skips macOS signing and publishes unsigned binaries. When `MACOS_SIGN_P12` is set, the companion macOS secrets below are required or the release fails.
  8. ### Prerequisites
  9. - An active [Apple Developer Program](https://developer.apple.com/programs/) membership.
  10. - A **Developer ID Application** certificate (not "Apple Development" or "Mac App Distribution").
  11. - An [App Store Connect API key](https://appstoreconnect.apple.com/access/integrations/api) with at least **Developer** access.
  12. ### One-time setup
  13. #### 1. Create the signing certificate (OpenSSL, no Mac/Xcode)
  14. Work in a private directory. Keep the private key offline and never commit it.
  15. ```sh
  16. mkdir -p ~/apple-signing && cd ~/apple-signing
  17. chmod 700 .
  18. openssl genrsa -out developer_id_app.key 2048
  19. openssl req -new -key developer_id_app.key -out developer_id_app.csr \
  20. -subj "/emailAddress=you@example.com/CN=Your Name/C=GB"
  21. ```
  22. 1. Open [Certificates, Identifiers & Profiles](https://developer.apple.com/account/resources/certificates/list).
  23. 2. Create a certificate of type **Developer ID Application**. Prefer **G2 Sub-CA** if the portal asks.
  24. 3. Upload `developer_id_app.csr` and download the resulting `.cer` (often named `developerID_application.cer`).
  25. Build a `.p12` that includes Apple's Developer ID G2 intermediate:
  26. ```sh
  27. curl -fsSLO https://www.apple.com/certificateauthority/DeveloperIDG2CA.cer
  28. openssl x509 -inform DER -in developerID_application.cer -out developerID_application.pem
  29. openssl x509 -inform DER -in DeveloperIDG2CA.cer -out DeveloperIDG2CA.pem
  30. # Export password becomes MACOS_SIGN_PASSWORD.
  31. # On OpenSSL 3 (e.g. Fedora), -legacy improves compatibility with some tooling:
  32. openssl pkcs12 -export -legacy \
  33. -inkey developer_id_app.key \
  34. -in developerID_application.pem \
  35. -certfile DeveloperIDG2CA.pem \
  36. -out Certificates.p12
  37. ```
  38. If you already have a Mac with the certificate in Keychain Access, you can export a `.p12` from there instead; the OpenSSL path above is enough when you do not.
  39. #### 2. Create the notarization API key
  40. 1. Open [App Store Connect → Users and Access → Integrations → App Store Connect API](https://appstoreconnect.apple.com/access/integrations/api).
  41. 2. Create a key with **Developer** role (or Admin).
  42. 3. Download the `.p8` file once (it cannot be downloaded again). Note the **Key ID** shown in the portal and the **Issuer ID** at the top of the API keys page.
  43. #### 3. Base64-encode the key files
  44. Run on a machine that has the files (Linux or macOS):
  45. ```sh
  46. base64 -w0 < ./Certificates.p12 # MACOS_SIGN_P12
  47. base64 -w0 < ./AuthKey_XXXXXX.p8 # MACOS_NOTARY_KEY
  48. ```
  49. On macOS without GNU coreutils, use `base64 -i file | tr -d '\n'`.
  50. #### 4. Add GitHub repository secrets
  51. In **Settings → Secrets and variables → Actions**, create:
  52. | Secret | Value |
  53. |--------|-------|
  54. | `MACOS_SIGN_P12` | Base64 contents of the `.p12` file |
  55. | `MACOS_SIGN_PASSWORD` | Password used when exporting the `.p12` |
  56. | `MACOS_NOTARY_KEY` | Base64 contents of the `.p8` file |
  57. | `MACOS_NOTARY_KEY_ID` | Key ID from App Store Connect (e.g. `ABC123DEF4`) |
  58. | `MACOS_NOTARY_ISSUER_ID` | Issuer UUID from App Store Connect |
  59. All five must be present for signing to run. GoReleaser enables the step when `MACOS_SIGN_P12` is set; missing companion secrets will fail that release.
  60. ### Renewal
  61. | Item | Typical lifetime | What to do |
  62. |------|------------------|------------|
  63. | Developer ID Application certificate | ~5 years | Create a new certificate in the Apple portal, export a new `.p12`, update `MACOS_SIGN_P12` and `MACOS_SIGN_PASSWORD`. |
  64. | App Store Connect API key | Does not expire, but can be revoked | Create a new key if compromised or lost; update `MACOS_NOTARY_KEY`, `MACOS_NOTARY_KEY_ID`, and optionally `MACOS_NOTARY_ISSUER_ID`. |
  65. | Apple Developer Program | Annual subscription | Renew membership before it lapses; existing certificates stop working if the account is inactive. |
  66. After updating secrets, the next release on `main` (via semantic-release) will use the new credentials automatically.
  67. ### Verifying a signed release
  68. On a Mac, download a `OliveTin-darwin-*.tar.gz` release artifact and run:
  69. ```sh
  70. tar -xzf OliveTin-darwin-arm64.tar.gz
  71. spctl -a -vv -t execute OliveTin-darwin-arm64/OliveTin
  72. ```
  73. A signed and notarized binary should report `accepted` with `source=Notarized Developer ID`.
  74. ### Configuration reference
  75. - GoReleaser: `notarize.macos` in link:https://github.com/OliveTin/OliveTin/blob/main/.goreleaser.yml[`.goreleaser.yml`]
  76. - CI secrets: link:https://github.com/OliveTin/OliveTin/blob/main/.github/workflows/build-and-release.yml[`.github/workflows/build-and-release.yml`] (`release` step)
  77. - link:https://goreleaser.com/customization/notarize/[GoReleaser notarization docs]
  78. ## Windows release signing (SignPath)
  79. Windows Authenticode signing uses [SignPath Foundation](https://signpath.org/) (free for qualifying open-source projects). It does **not** use GoReleaser Pro.
  80. GoReleaser publishes a GitHub release **without** Windows zip/MSI assets. A separate `sign-windows` job submits the unsigned Windows files (as workflow artifacts) to SignPath, then uploads the signed zip/MSI and updates `checksums.txt` on the already-published release.
  81. Signed artifacts:
  82. * `OliveTin.exe` inside `OliveTin-windows-amd64.zip`
  83. * nested `OliveTin.exe` and the `OliveTin-windows-amd64.msi` installer (deep signing)
  84. If SignPath secrets/vars are missing or signing fails, the release still publishes; Windows assets are simply missing until a successful `sign-windows` run. Install URLs for the Windows zip may 404 until signing finishes.
  85. ### Prerequisites
  86. - Approval for the [SignPath Foundation open-source program](https://signpath.io/product/open-source).
  87. - The SignPath GitHub App installed on the OliveTin organization/repository.
  88. - A SignPath project linked to this repository, with a release signing policy.
  89. ### One-time setup
  90. #### 1. Apply for SignPath Foundation
  91. 1. Open https://signpath.io/product/open-source and apply with the OliveTin GitHub repository URL.
  92. 2. After approval, create (or confirm) the organization and project in the SignPath portal.
  93. #### 2. Install the SignPath GitHub App
  94. 1. Install the SignPath GitHub App and grant access to the OliveTin repository.
  95. 2. Link the Trusted Build System **GitHub.com** to the SignPath project (required so SignPath can verify the workflow artifact origin).
  96. #### 3. Create artifact configurations
  97. In the SignPath project, create two artifact configurations with these slugs (must match CI). Paste the XML from the reference copies in this repo (SignPath does **not** load them automatically):
  98. * slug `windows-zip` ← link:https://github.com/OliveTin/OliveTin/blob/main/docs/modules/dev/signpath/windows-zip.xml[`signpath/windows-zip.xml`]
  99. * slug `windows-msi` ← link:https://github.com/OliveTin/OliveTin/blob/main/docs/modules/dev/signpath/windows-msi.xml[`signpath/windows-msi.xml`]
  100. Use **Custom** XML in the SignPath UI and paste the file contents. Do **not** use **Upload an artifact sample** on these `.xml` files — SignPath will treat them as XML documents to sign (`xml-file`), which is unavailable on the Foundation/Open Source plan. See link:https://github.com/OliveTin/OliveTin/blob/main/docs/modules/dev/signpath/README.md[`signpath/README.md`].
  101. #### 4. Add GitHub secrets and variables
  102. In **Settings → Secrets and variables → Actions**:
  103. | Kind | Name | Value |
  104. |------|------|-------|
  105. | Secret | `SIGNPATH_API_TOKEN` | CI submitter API token from SignPath |
  106. | Variable | `SIGNPATH_ORGANIZATION_ID` | SignPath organization ID |
  107. | Variable | `SIGNPATH_PROJECT_SLUG` | SignPath project slug (e.g. `olivetin`) |
  108. | Variable | `SIGNPATH_SIGNING_POLICY_SLUG` | Signing policy slug (e.g. `release-signing`) |
  109. #### 5. Pipeline behaviour
  110. On a new semantic-release from `main`:
  111. 1. GoReleaser publishes container images and a GitHub release **without** Windows zip/MSI assets (those are built locally for SignPath only).
  112. 2. The build job uploads the unsigned Windows files as GitHub Actions artifacts.
  113. 3. The `sign-windows` job submits each artifact to SignPath, waits for completion, then runs `var/windows/signpath-publish-signed.sh` to upload the signed files and refresh `checksums.txt`.
  114. All jobs in this chain use GitHub-hosted runners (required by SignPath for OSS projects).
  115. ### Verifying a signed release
  116. On Windows, download `OliveTin-windows-amd64.msi` or extract `OliveTin.exe` from the zip, then either:
  117. * Right-click → **Properties** → **Digital Signatures**, or
  118. * Run:
  119. ```bat
  120. signtool verify /pa OliveTin.exe
  121. signtool verify /pa OliveTin-windows-amd64.msi
  122. ```
  123. ### Configuration reference
  124. - Release publish (no Windows assets initially): `release.draft: false` and `release.ids` in link:https://github.com/OliveTin/OliveTin/blob/main/.goreleaser.yml[`.goreleaser.yml`]
  125. - CI job: `sign-windows` in link:https://github.com/OliveTin/OliveTin/blob/main/.github/workflows/build-and-release.yml[`.github/workflows/build-and-release.yml`]
  126. - Publish helper: link:https://github.com/OliveTin/OliveTin/blob/main/var/windows/signpath-publish-signed.sh[`var/windows/signpath-publish-signed.sh`]
  127. - SignPath artifact configs (reference only): link:https://github.com/OliveTin/OliveTin/blob/main/docs/modules/dev/signpath/windows-zip.xml[`signpath/windows-zip.xml`], link:https://github.com/OliveTin/OliveTin/blob/main/docs/modules/dev/signpath/windows-msi.xml[`signpath/windows-msi.xml`]
  128. - link:https://docs.signpath.io/trusted-build-systems/github[SignPath GitHub Actions docs]
  129. - link:https://docs.signpath.io/artifact-configuration/examples[SignPath artifact configuration examples]