Compare commits

...
2 Commits
Author SHA1 Message Date
noah 2c58cbac48 Merge pull request 'Sign the Windows build with Azure Artifact Signing' (#17) from windows-signing into main 2026-11-02 19:51:15 -07:00
noahandClaude Opus 5.5 174b162dfd Sign the Windows build with Azure Artifact Signing
- ci/sign-windows.sh signs alkane-toolkit.exe from Linux with jsign through
  the blueflaresigning account (RFC 3161 timestamped), using the
  least-privilege CI service principal alkane-toolkit-ci-signer. It is a
  no-op until the repository variable AZURE_SIGNING_PROFILE names a
  certificate profile; after that any signing failure fails the build.
- release.yml and next.yml sign before packaging; windows-native.yml checks
  the signature with Get-AuthenticodeSignature on real Windows and requires
  Valid once signing is on.
- CI image adds a Java runtime and a checksum-pinned jsign 7.6 (re-pinned);
  windows-ci.sh fetches the same jar on older images.
- scripts/enable-windows-signing.sh turns signing on after Microsoft
  approves the publisher identity validation: creates the PublicTrust
  certificate profile, narrows the signer role to it, sets the variable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 20:38:21 -06:00
15 changed files with 254 additions and 15 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ jobs:
publish: publish:
runs-on: alkane-verify runs-on: alkane-verify
container: container:
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041 image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
permissions: permissions:
contents: read contents: read
steps: steps:
+1 -1
View File
@@ -9,7 +9,7 @@ jobs:
publish: publish:
runs-on: alkane-verify runs-on: alkane-verify
container: container:
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041 image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
permissions: permissions:
actions: read actions: read
contents: write contents: write
+10 -2
View File
@@ -17,7 +17,7 @@ jobs:
windows: windows:
runs-on: alkane-ci runs-on: alkane-ci
container: container:
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041 image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
env: env:
CARGO_TARGET_DIR: target CARGO_TARGET_DIR: target
CARGO_BUILD_JOBS: 2 CARGO_BUILD_JOBS: 2
@@ -64,6 +64,14 @@ jobs:
- name: Build Windows candidate - name: Build Windows candidate
if: steps.version.outputs.release == 'true' if: steps.version.outputs.release == 'true'
run: bash ci/windows-ci.sh build run: bash ci/windows-ci.sh build
- name: Sign Windows candidate (Azure Artifact Signing)
if: steps.version.outputs.release == 'true'
env:
AZURE_SIGNING_PROFILE: ${{ vars.AZURE_SIGNING_PROFILE }}
AZURE_SIGNING_TENANT_ID: ${{ secrets.AZURE_SIGNING_TENANT_ID }}
AZURE_SIGNING_CLIENT_ID: ${{ secrets.AZURE_SIGNING_CLIENT_ID }}
AZURE_SIGNING_CLIENT_SECRET: ${{ secrets.AZURE_SIGNING_CLIENT_SECRET }}
run: bash ci/windows-ci.sh sign
- name: Package Windows candidate - name: Package Windows candidate
if: steps.version.outputs.release == 'true' if: steps.version.outputs.release == 'true'
run: bash ci/windows-ci.sh package "${{ steps.version.outputs.version }}" run: bash ci/windows-ci.sh package "${{ steps.version.outputs.version }}"
@@ -80,7 +88,7 @@ jobs:
needs: windows needs: windows
runs-on: alkane-ci runs-on: alkane-ci
container: container:
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041 image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
env: env:
CARGO_TARGET_DIR: target CARGO_TARGET_DIR: target
CARGO_BUILD_JOBS: 2 CARGO_BUILD_JOBS: 2
+10 -2
View File
@@ -23,7 +23,7 @@ jobs:
windows: windows:
runs-on: alkane-ci runs-on: alkane-ci
container: container:
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041 image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
env: env:
CARGO_TARGET_DIR: target CARGO_TARGET_DIR: target
CARGO_BUILD_JOBS: 2 CARGO_BUILD_JOBS: 2
@@ -91,6 +91,14 @@ jobs:
- name: Headless UI self-test (Windows build, under Wine) - name: Headless UI self-test (Windows build, under Wine)
run: bash ci/windows-ci.sh selftest run: bash ci/windows-ci.sh selftest
- name: Sign Windows executable (Azure Artifact Signing)
env:
AZURE_SIGNING_PROFILE: ${{ vars.AZURE_SIGNING_PROFILE }}
AZURE_SIGNING_TENANT_ID: ${{ secrets.AZURE_SIGNING_TENANT_ID }}
AZURE_SIGNING_CLIENT_ID: ${{ secrets.AZURE_SIGNING_CLIENT_ID }}
AZURE_SIGNING_CLIENT_SECRET: ${{ secrets.AZURE_SIGNING_CLIENT_SECRET }}
run: bash ci/windows-ci.sh sign
- name: Package Windows artifact - name: Package Windows artifact
if: steps.ver.outputs.release == 'true' if: steps.ver.outputs.release == 'true'
run: bash ci/windows-ci.sh package "${{ steps.ver.outputs.version }}" run: bash ci/windows-ci.sh package "${{ steps.ver.outputs.version }}"
@@ -120,7 +128,7 @@ jobs:
needs: windows needs: windows
runs-on: alkane-ci runs-on: alkane-ci
container: container:
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041 image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
env: env:
CARGO_TARGET_DIR: target CARGO_TARGET_DIR: target
CARGO_BUILD_JOBS: 2 CARGO_BUILD_JOBS: 2
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
check: check:
runs-on: alkane-fast runs-on: alkane-fast
container: container:
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041 image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
env: env:
CARGO_BUILD_JOBS: 2 CARGO_BUILD_JOBS: 2
steps: steps:
+2 -2
View File
@@ -13,7 +13,7 @@ jobs:
verify: verify:
runs-on: alkane-verify runs-on: alkane-verify
container: container:
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041 image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
outputs: outputs:
surface: ${{ steps.surface.outputs.surface }} surface: ${{ steps.surface.outputs.surface }}
env: env:
@@ -203,7 +203,7 @@ jobs:
if: needs.verify.outputs.surface == 'full' if: needs.verify.outputs.surface == 'full'
runs-on: alkane-verify runs-on: alkane-verify
container: container:
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041 image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
env: env:
CARGO_TARGET_DIR: target CARGO_TARGET_DIR: target
CARGO_BUILD_JOBS: 2 CARGO_BUILD_JOBS: 2
+12
View File
@@ -63,6 +63,18 @@ jobs:
$os = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' $os = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
"Testing run $env:RUN_ID on Windows $($os.DisplayVersion) build $($os.CurrentBuild)" "Testing run $env:RUN_ID on Windows $($os.DisplayVersion) build $($os.CurrentBuild)"
- name: Authenticode signature (native Windows)
env:
SIGNING_ENABLED: ${{ vars.AZURE_SIGNING_PROFILE }}
run: |
# Windows itself judges the signature: chain to a trusted root,
# intact file hash, valid timestamp. Required once signing is on.
$sig = Get-AuthenticodeSignature "$env:ALKANE_NATIVE\alkane-toolkit.exe"
Write-Host "Signature: $($sig.Status) $($sig.StatusMessage)"
if ($sig.SignerCertificate) { Write-Host "Signer: $($sig.SignerCertificate.Subject)" }
if ($sig.TimeStamperCertificate) { Write-Host "Timestamp: $($sig.TimeStamperCertificate.Subject)" }
if ($env:SIGNING_ENABLED -and $sig.Status -ne 'Valid') { exit 1 }
- name: Unit tests (native Windows) - name: Unit tests (native Windows)
run: | run: |
$failed = @() $failed = @()
+2 -1
View File
@@ -13,7 +13,8 @@ case "$mode" in
# Windows cross build (mingw-w64, posix threads) + Wine for its tests. # Windows cross build (mingw-w64, posix threads) + Wine for its tests.
windows) packages=(libssl-dev pkg-config ca-certificates windows) packages=(libssl-dev pkg-config ca-certificates
gcc-mingw-w64-x86-64-posix g++-mingw-w64-x86-64-posix gcc-mingw-w64-x86-64-posix g++-mingw-w64-x86-64-posix
binutils-mingw-w64-x86-64 mingw-w64-x86-64-dev wine wine64 xvfb xauth) ;; binutils-mingw-w64-x86-64 mingw-w64-x86-64-dev wine wine64 xvfb xauth
openjdk-21-jre-headless) ;;
*) echo "unknown dependency set: $mode" >&2; exit 2 ;; *) echo "unknown dependency set: $mode" >&2; exit 2 ;;
esac esac
+13 -1
View File
@@ -9,6 +9,8 @@
# scripts/build-wx-windows.sh and stamped with the source digest the same # scripts/build-wx-windows.sh and stamped with the source digest the same
# way as the wxGTK prefix (ci/ensure-wx-prefix.sh rebuilds on a mismatch) # way as the wxGTK prefix (ci/ensure-wx-prefix.sh rebuilds on a mismatch)
# - Wine with an initialised prefix, to run the Windows tests and self-test # - Wine with an initialised prefix, to run the Windows tests and self-test
# - a Java runtime and jsign (checksum-pinned), to Authenticode-sign the .exe
# through Azure Artifact Signing (ci/sign-windows.sh)
# #
# Build and push from the workstation with ci/images/build-image.sh. # Build and push from the workstation with ci/images/build-image.sh.
ARG BASE=gitea.bluefla.re/blueflare/alkane-ci@sha256:9d2a992bbcb91014af3c85d2e1ec8c5990701cecf83fd06c8d46f9ef13dbd948 ARG BASE=gitea.bluefla.re/blueflare/alkane-ci@sha256:9d2a992bbcb91014af3c85d2e1ec8c5990701cecf83fd06c8d46f9ef13dbd948
@@ -18,9 +20,18 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \ && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
gcc-mingw-w64-x86-64-posix g++-mingw-w64-x86-64-posix \ gcc-mingw-w64-x86-64-posix g++-mingw-w64-x86-64-posix \
binutils-mingw-w64-x86-64 mingw-w64-x86-64-dev \ binutils-mingw-w64-x86-64 mingw-w64-x86-64-dev \
wine wine64 xvfb xauth \ wine wine64 xvfb xauth openjdk-21-jre-headless \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# jsign (Maven Central net.jsign:jsign; keep in step with ci/windows-ci.sh).
ARG JSIGN_VERSION=7.6
ARG JSIGN_SHA256=6cf58aa080e7ff82656f320cff8d4a3bff30408df8766806dcba3740dd839fa5
RUN mkdir -p /opt/jsign \
&& curl -sSfL -o /opt/jsign/jsign.jar \
"https://repo1.maven.org/maven2/net/jsign/jsign/${JSIGN_VERSION}/jsign-${JSIGN_VERSION}.jar" \
&& echo "${JSIGN_SHA256} /opt/jsign/jsign.jar" | sha256sum -c - \
&& java -jar /opt/jsign/jsign.jar --help >/dev/null
RUN rustup target add x86_64-pc-windows-gnu RUN rustup target add x86_64-pc-windows-gnu
# The build context is the repository root, filtered by # The build context is the repository root, filtered by
@@ -44,4 +55,5 @@ RUN test -s /root/.cache/wx-3.3.3-mingw/lib/libwx_mswu-3.3-x86_64-w64-mingw32.a
&& test -s /root/.cache/wx-3.3.3-linux/lib/libwx_gtk3u-3.3.a \ && test -s /root/.cache/wx-3.3.3-linux/lib/libwx_gtk3u-3.3.a \
&& x86_64-w64-mingw32-g++-posix --version >/dev/null \ && x86_64-w64-mingw32-g++-posix --version >/dev/null \
&& wine --version \ && wine --version \
&& test -s /opt/jsign/jsign.jar \
&& rustup target list --installed | grep -qx x86_64-pc-windows-gnu && rustup target list --installed | grep -qx x86_64-pc-windows-gnu
+1 -1
View File
@@ -1 +1 @@
gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041 gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
+88
View File
@@ -0,0 +1,88 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
# Authenticode-sign Windows executables with Azure Artifact Signing (formerly
# Trusted Signing), from Linux, with jsign. Every signature is RFC 3161
# timestamped: the signing certificates live only a few days, the timestamp is
# what keeps a signature valid after that.
#
# ci/sign-windows.sh FILE.exe [FILE.exe ...]
#
# Configuration (environment):
# AZURE_SIGNING_PROFILE certificate profile name; EMPTY = signing not set
# up yet: the files are left unsigned (exit 0)
# AZURE_SIGNING_ACCOUNT signing account (default blueflaresigning)
# AZURE_SIGNING_ENDPOINT account endpoint (default https://wus2.codesigning.azure.net)
# Credentials, one of:
# AZURE_SIGNING_TENANT_ID + AZURE_SIGNING_CLIENT_ID + AZURE_SIGNING_CLIENT_SECRET
# (the CI service principal alkane-toolkit-ci-signer, role
# "Artifact Signing Certificate Profile Signer" on the account only)
# AZURE_SIGNING_TOKEN an access token for https://codesigning.azure.net,
# e.g. from `az account get-access-token --resource https://codesigning.azure.net`
# ALKANE_JSIGN_JAR jsign jar (default /opt/jsign/jsign.jar, from the CI image)
#
# Once a profile is configured, any failure fails the job: a release is never
# shipped half-signed or silently unsigned.
set -euo pipefail
[ "$#" -gt 0 ] || { sed -n '3,25p' "$0" >&2; exit 2; }
profile="${AZURE_SIGNING_PROFILE:-}"
if [ -z "$profile" ]; then
echo "Windows code signing is not enabled (AZURE_SIGNING_PROFILE unset); leaving $* unsigned"
exit 0
fi
account="${AZURE_SIGNING_ACCOUNT:-blueflaresigning}"
endpoint="${AZURE_SIGNING_ENDPOINT:-https://wus2.codesigning.azure.net}"
jar="${ALKANE_JSIGN_JAR:-/opt/jsign/jsign.jar}"
[ -f "$jar" ] || { echo "jsign not found at $jar" >&2; exit 1; }
if [ -z "${AZURE_SIGNING_TOKEN:-}" ]; then
: "${AZURE_SIGNING_TENANT_ID:?signing credentials missing}"
: "${AZURE_SIGNING_CLIENT_ID:?signing credentials missing}"
: "${AZURE_SIGNING_CLIENT_SECRET:?signing credentials missing}"
# Client-credentials token for the signing service. The secret and token
# stay in this process's environment, never on a command line.
AZURE_SIGNING_TOKEN="$(python3 - <<'PY'
import json, os, sys, urllib.parse, urllib.request
body = urllib.parse.urlencode({
"grant_type": "client_credentials",
"client_id": os.environ["AZURE_SIGNING_CLIENT_ID"],
"client_secret": os.environ["AZURE_SIGNING_CLIENT_SECRET"],
"scope": "https://codesigning.azure.net/.default",
}).encode()
url = f"https://login.microsoftonline.com/{os.environ['AZURE_SIGNING_TENANT_ID']}/oauth2/v2.0/token"
try:
with urllib.request.urlopen(url, body, timeout=60) as r:
print(json.load(r)["access_token"])
except Exception as e:
sys.exit(f"could not get a signing token: {e}")
PY
)"
fi
export AZURE_SIGNING_TOKEN
for file in "$@"; do
java -jar "$jar" \
--storetype TRUSTEDSIGNING \
--keystore "${endpoint#https://}" \
--storepass env:AZURE_SIGNING_TOKEN \
--alias "$account/$profile" \
--alg SHA-256 \
--tsaurl http://timestamp.acs.microsoft.com --tsmode RFC3161 \
--tsretries 3 --tsretrywait 10 \
--name "Alkane Toolkit" \
--url https://gitea.bluefla.re/blueflare/alkane-toolkit \
"$file"
# jsign fails on any error; also make sure a signature actually landed in
# the PE certificate table before the file goes anywhere.
python3 - "$file" <<'PY'
import struct, sys
data = open(sys.argv[1], "rb").read()
pe = struct.unpack_from("<I", data, 0x3C)[0]
magic = struct.unpack_from("<H", data, pe + 24)[0]
dirs = pe + 24 + (96 if magic == 0x10B else 112)
offset, size = struct.unpack_from("<II", data, dirs + 4 * 8) # IMAGE_DIRECTORY_ENTRY_SECURITY
if size == 0:
sys.exit(f"{sys.argv[1]}: no Authenticode signature after signing")
print(f"{sys.argv[1]}: signed ({size} byte certificate table)")
PY
done
+5 -2
View File
@@ -43,6 +43,7 @@ def check_workflow_contract() -> None:
"Clippy (Windows target, warnings are errors)", "Build release (Windows)", "Clippy (Windows target, warnings are errors)", "Build release (Windows)",
"Unit tests (Windows build, under Wine)", "Unit tests (Windows build, under Wine)",
"Headless UI self-test (Windows build, under Wine)", "Headless UI self-test (Windows build, under Wine)",
"Sign Windows executable (Azure Artifact Signing)",
"Package Windows artifact", "Clean generated Toolkit build", "Package Windows artifact", "Clean generated Toolkit build",
)), )),
("next.yml", "next", "candidate", ( ("next.yml", "next", "candidate", (
@@ -50,7 +51,8 @@ def check_workflow_contract() -> None:
"Create private prerelease", "Clean generated Toolkit build", "Create private prerelease", "Clean generated Toolkit build",
)), )),
("next.yml", "next", "windows", ( ("next.yml", "next", "windows", (
"Build Windows candidate", "Package Windows candidate", "Build Windows candidate", "Sign Windows candidate (Azure Artifact Signing)",
"Package Windows candidate",
"Clean generated Toolkit build", "Clean generated Toolkit build",
)), )),
("verify.yml", "main", "verify", ( ("verify.yml", "main", "verify", (
@@ -83,7 +85,8 @@ def check_workflow_contract() -> None:
condition = steps[position].get("if") condition = steps[position].get("if")
if gate in {"Create Gitea release + upload artifact", if gate in {"Create Gitea release + upload artifact",
"Create private prerelease", "Package Windows artifact", "Create private prerelease", "Package Windows artifact",
"Build Windows candidate", "Package Windows candidate"}: "Build Windows candidate", "Package Windows candidate",
"Sign Windows candidate (Azure Artifact Signing)"}:
assert condition is not None and "release == 'true'" in condition, path assert condition is not None and "release == 'true'" in condition, path
elif filename == "verify.yml" and gate in { elif filename == "verify.yml" and gate in {
"Build", "Unit tests", "Microbenchmarks", "Build", "Unit tests", "Microbenchmarks",
+16 -1
View File
@@ -8,6 +8,9 @@
# windows-ci.sh build release alkane-toolkit.exe # windows-ci.sh build release alkane-toolkit.exe
# windows-ci.sh test all unit tests, run under Wine # windows-ci.sh test all unit tests, run under Wine
# windows-ci.sh selftest headless UI self-test under Wine + Xvfb # windows-ci.sh selftest headless UI self-test under Wine + Xvfb
# windows-ci.sh sign Authenticode-sign alkane-toolkit.exe through
# Azure Artifact Signing (ci/sign-windows.sh;
# a no-op until AZURE_SIGNING_PROFILE is set)
# windows-ci.sh package VERSION dist/alkane-toolkit-vVERSION-windows-x86_64.zip # windows-ci.sh package VERSION dist/alkane-toolkit-vVERSION-windows-x86_64.zip
# windows-ci.sh test-bundle dist/alkane-toolkit-windows-tests.zip (for # windows-ci.sh test-bundle dist/alkane-toolkit-windows-tests.zip (for
# the native Windows job) # the native Windows job)
@@ -30,6 +33,15 @@ case "${1:-}" in
toolchain) toolchain)
bash ci/ensure-build-deps.sh windows bash ci/ensure-build-deps.sh windows
rustup target list --installed | grep -qx "$target" || rustup target add "$target" rustup target list --installed | grep -qx "$target" || rustup target add "$target"
# jsign ships in the CI image; fetch the same pinned jar on older images.
jsign_version=7.6
jsign_sha256=6cf58aa080e7ff82656f320cff8d4a3bff30408df8766806dcba3740dd839fa5
if [ ! -s /opt/jsign/jsign.jar ]; then
mkdir -p /opt/jsign
curl -sSfL -o /opt/jsign/jsign.jar \
"https://repo1.maven.org/maven2/net/jsign/jsign/$jsign_version/jsign-$jsign_version.jar"
echo "$jsign_sha256 /opt/jsign/jsign.jar" | sha256sum -c -
fi
;; ;;
clippy) clippy)
rustup component add clippy >/dev/null 2>&1 || true rustup component add clippy >/dev/null 2>&1 || true
@@ -53,6 +65,9 @@ case "${1:-}" in
selftest) selftest)
bash scripts/ui-selftest-windows.sh "$exe" bash scripts/ui-selftest-windows.sh "$exe"
;; ;;
sign)
bash ci/sign-windows.sh "$exe"
;;
package) package)
python3 ci/package-windows.py release "${2:?usage: windows-ci.sh package VERSION}" "$exe" dist python3 ci/package-windows.py release "${2:?usage: windows-ci.sh package VERSION}" "$exe" dist
;; ;;
@@ -64,7 +79,7 @@ case "${1:-}" in
dist/alkane-toolkit-windows-tests.zip dist/alkane-toolkit-windows-tests.zip
;; ;;
*) *)
sed -n '3,16p' "$0" >&2 sed -n '3,19p' "$0" >&2
exit 2 exit 2
;; ;;
esac esac
+34
View File
@@ -59,6 +59,40 @@ target and a prebuilt wxMSW prefix to the Linux image. Rebuild it with
`ci/images/build-image.sh TAG` from the workstation that holds the registry `ci/images/build-image.sh TAG` from the workstation that holds the registry
credential; the script pins the new digest everywhere. credential; the script pins the new digest everywhere.
## Code signing
Release and `-rc` executables are Authenticode-signed with Azure Artifact
Signing (formerly Trusted Signing), so Windows and SmartScreen show
"Blueflare" as the verified publisher instead of "Unknown publisher".
| Piece | Where |
|-------|-------|
| Signing account | `blueflaresigning` (Basic), resource group `rg-blueflare-signing`, West US 2, endpoint `https://wus2.codesigning.azure.net` |
| CI identity | service principal `alkane-toolkit-ci-signer`, role "Artifact Signing Certificate Profile Signer" on the certificate profile only; Gitea secrets `AZURE_SIGNING_TENANT_ID`, `AZURE_SIGNING_CLIENT_ID`, `AZURE_SIGNING_CLIENT_SECRET` (secret expires 2027-11-03) |
| Switch | Gitea repository variable `AZURE_SIGNING_PROFILE` (certificate profile name); unset = builds stay unsigned |
| Signer | `ci/sign-windows.sh` (jsign from the CI image, RFC 3161 timestamp from `timestamp.acs.microsoft.com`) |
| Check | `windows-native.yml` requires `Get-AuthenticodeSignature` = Valid on real Windows once signing is on |
Turning it on, once Microsoft approves the identity validation (portal:
signing account > Identity validations):
```sh
scripts/enable-windows-signing.sh <identity-validation-id>
```
It creates the PublicTrust certificate profile, narrows the CI identity to it,
and sets `AZURE_SIGNING_PROFILE`. From then on a signing failure fails the
release. Rotate the CI secret before it expires with
`az ad sp credential reset --id <appId> --years 1` and update the Gitea secret.
Sign by hand (any machine with Java, `az login` and the Signer role):
```sh
AZURE_SIGNING_PROFILE=alkane-toolkit ALKANE_JSIGN_JAR=jsign.jar \
AZURE_SIGNING_TOKEN=$(az account get-access-token --resource https://codesigning.azure.net --query accessToken -o tsv) \
ci/sign-windows.sh alkane-toolkit.exe
```
## Native Windows runner ## Native Windows runner
`windows-native.yml` runs on the self-hosted runner `win11-test-vm` `windows-native.yml` runs on the self-hosted runner `win11-test-vm`
+58
View File
@@ -0,0 +1,58 @@
#!/bin/sh
# Turn on Authenticode signing of the Windows build, once Microsoft has
# approved the publisher identity validation for the Artifact Signing account.
#
# scripts/enable-windows-signing.sh IDENTITY_VALIDATION_ID [PROFILE]
#
# IDENTITY_VALIDATION_ID is shown in the Azure portal: signing account
# "blueflaresigning" > Objects > Identity validations > (approved entry).
# The script
# 1. creates the PublicTrust certificate profile PROFILE (default
# alkane-toolkit) bound to that identity,
# 2. narrows the CI signer's role from the whole account to that profile,
# 3. sets the Gitea repository variable AZURE_SIGNING_PROFILE, which makes
# ci/sign-windows.sh sign every release and candidate from then on.
#
# Run on the workstation: it needs `az login` as an account owner and the
# Gitea admin token (~/.config/gitea/token), neither of which CI ever sees.
# Re-running is safe.
set -eu
IVID=${1:?usage: enable-windows-signing.sh IDENTITY_VALIDATION_ID [PROFILE]}
PROFILE=${2:-alkane-toolkit}
RG=rg-blueflare-signing
ACCOUNT=blueflaresigning
SIGNER=alkane-toolkit-ci-signer
REPO=blueflare/alkane-toolkit
TOKEN_FILE=${GITEA_TOKEN_FILE:-$HOME/.config/gitea/token}
if ! az trustedsigning certificate-profile show -g "$RG" --account-name "$ACCOUNT" \
-n "$PROFILE" --only-show-errors -o none 2>/dev/null; then
az trustedsigning certificate-profile create -g "$RG" --account-name "$ACCOUNT" \
-n "$PROFILE" --profile-type PublicTrust --identity-validation-id "$IVID" \
--only-show-errors -o none
fi
az trustedsigning certificate-profile show -g "$RG" --account-name "$ACCOUNT" -n "$PROFILE" \
--only-show-errors --query "{profile:name, state:provisioningState, status:status}" -o table
# Least privilege: the CI identity may sign with this profile and nothing else.
profile_id=$(az trustedsigning certificate-profile show -g "$RG" --account-name "$ACCOUNT" \
-n "$PROFILE" --only-show-errors --query id -o tsv)
account_id=${profile_id%/certificateProfiles/*}
sp=$(az ad sp list --display-name "$SIGNER" --query "[0].id" -o tsv)
role="Artifact Signing Certificate Profile Signer"
az role assignment create --assignee-object-id "$sp" --assignee-principal-type ServicePrincipal \
--role "$role" --scope "$profile_id" -o none
az role assignment delete --assignee "$sp" --role "$role" --scope "$account_id" 2>/dev/null || true
# Switch signing on for CI (repository variable, not a secret).
api=https://gitea.bluefla.re/api/v1/repos/$REPO/actions/variables/AZURE_SIGNING_PROFILE
body=$(printf '{"value":"%s"}' "$PROFILE")
auth() { printf 'header = "Authorization: token %s"\n' "$(cat "$TOKEN_FILE")"; }
code=$(auth | curl -sS --config - -X PUT -H 'Content-Type: application/json' -d "$body" \
-o /dev/null -w '%{http_code}' "$api")
[ "$code" = 204 ] || [ "$code" = 201 ] || {
code=$(auth | curl -sS --config - -X POST -H 'Content-Type: application/json' -d "$body" \
-o /dev/null -w '%{http_code}' "$api")
}
case "$code" in 201|204) echo "Gitea AZURE_SIGNING_PROFILE=$PROFILE: signing is on" ;;
*) echo "setting the Gitea variable failed (HTTP $code)" >&2; exit 1 ;; esac