- 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>
59 lines
3.1 KiB
Bash
Executable File
59 lines
3.1 KiB
Bash
Executable File
#!/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
|