Sign Windows release and nightly builds in CI (#17305)

* Sign Windows release and nightly builds in CI

* Replace the README's SignPath signing policy with a signed-builds note
This commit is contained in:
SoftFever authored and GitHub committed 2026-11-06 13:33:40 +08:00
1 parent c78272f583
commit 73e64d3bc5
5 files changed
+283 -11

No files matched your search

+8
View File
@@ -27,6 +27,7 @@ on:
- 'scripts/test_prune_cached_presets.ps1'
- 'scripts/flatpak/**'
- 'scripts/msix/**'
- 'scripts/sign_windows.ps1'
- 'tests/**'
pull_request:
@@ -53,6 +54,7 @@ on:
- 'scripts/test_prune_cached_presets.ps1'
- 'scripts/flatpak/**'
- 'scripts/msix/**'
- 'scripts/sign_windows.ps1'
- 'tests/**'
@@ -128,6 +130,12 @@ jobs:
&& '[{"arch":"x64","os":"orca-win-server","compiler":"clang"}]'
|| '[{"arch":"x64","os":"windows-latest","compiler":"clang"},{"arch":"arm64","os":"windows-11-vs2026-arm","compiler":"clang"}]') }}
needs: check_build_script
# id-token lets release builds sign through Google Cloud Workload Identity Federation (see
# "Configure code signing" in build_orca.yml); the rest is what the build already used.
permissions:
actions: write
contents: write
id-token: write
# Don't run scheduled builds on forks:
if: ${{ !cancelled() && needs.check_build_script.result == 'success' && (github.event_name != 'schedule' || github.repository == 'OrcaSlicer/OrcaSlicer') }}
uses: ./.github/workflows/build_check_cache.yml
+90
View File
@@ -35,6 +35,8 @@ jobs:
ORCA_UPDATER_SIG_KEY: ${{ secrets.ORCA_UPDATER_SIG_KEY }}
NSIS_VERSION: '3.13'
NSIS_SHA256: BA63DFFC4410EE89193E1CB5A41989991BD77C61068DA17E3156D136B7B0B3D8
JSIGN_VERSION: '7.6'
JSIGN_SHA256: 6CF58AA080E7FF82656F320CFF8D4A3BFF30408DF8766806DCBA3740DD839FA5
steps:
- name: Checkout
@@ -473,6 +475,38 @@ jobs:
path: ${{ runner.temp }}/nsis
key: nsis-${{ env.NSIS_VERSION }}
# Windows release builds are Authenticode-signed with the company's key in Google Cloud KMS
# (README, Code Signing Policy): pushes, schedules and manual runs of main and release/* in
# this repository, once the WINDOWS_SIGN_* variables are set. The Workload Identity provider
# accepts tokens from nothing else. This runs before the build so that CMake wires signing
# into the NSIS installer.
- name: Configure code signing
id: codesign
if: runner.os == 'Windows' && github.repository == 'OrcaSlicer/OrcaSlicer' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) && github.event_name != 'pull_request' && vars.WINDOWS_SIGN_KMS_KEY != ''
shell: pwsh
env:
CERT_CHAIN: ${{ vars.WINDOWS_SIGN_CERT_CHAIN }}
KMS_KEY: ${{ vars.WINDOWS_SIGN_KMS_KEY }}
run: |
$jar = Join-Path $env:RUNNER_TEMP "jsign-$env:JSIGN_VERSION.jar"
curl.exe -fsSL --retry 5 --retry-all-errors --retry-delay 15 -o $jar "https://github.com/ebourg/jsign/releases/download/$env:JSIGN_VERSION/jsign-$env:JSIGN_VERSION.jar"
if ($LASTEXITCODE -ne 0) { throw "Jsign $env:JSIGN_VERSION download failed." }
if ((Get-FileHash $jar -Algorithm SHA256).Hash -ne $env:JSIGN_SHA256) {
throw "Jsign $env:JSIGN_VERSION does not match its pinned SHA256."
}
$cert = Join-Path $env:RUNNER_TEMP 'codesign-chain.pem'
Set-Content -LiteralPath $cert -Value $env:CERT_CHAIN
"ORCA_SIGN_JSIGN=$jar" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
"ORCA_SIGN_CERTFILE=$cert" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
"ORCA_SIGN_KMS_KEY=$env:KMS_KEY" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
- name: Set up Java for code signing
if: steps.codesign.outcome == 'success'
uses: actions/setup-java@v6
with:
distribution: microsoft
java-version: '21'
- name: Build slicer Win
if: runner.os == 'Windows'
working-directory: ${{ github.workspace }}
@@ -492,6 +526,33 @@ jobs:
# the checkout cpack re-installs from when it builds the NSIS installer.
run: scripts\build_preset_cache.bat --prune-source "%BUILD_DIR%" "resources\profiles" "%BUILD_DIR%\OrcaSlicer\resources\profiles"
# Taken after the build because the token lasts an hour, which covers signing, the installer
# build and the checks.
- name: Authenticate to Google Cloud for code signing
id: codesign_auth
if: steps.codesign.outcome == 'success'
uses: google-github-actions/auth@v3
with:
workload_identity_provider: ${{ vars.WINDOWS_SIGN_WIF_PROVIDER }}
service_account: ${{ vars.WINDOWS_SIGN_SERVICE_ACCOUNT }}
token_format: access_token
create_credentials_file: false
# Signs what the portable zip, the artifact and the MSIX package ship, the profile validator,
# and the NSIS plugins the installer carries. The installer build signs its own copy of the
# app, since cpack installs the files again.
- name: Sign Windows binaries
if: steps.codesign.outcome == 'success'
shell: pwsh
env:
ORCA_SIGN_TOKEN: ${{ steps.codesign_auth.outputs.access_token }}
run: |
$paths = @("$env:BUILD_DIR/OrcaSlicer")
foreach ($extra in 'build/src/Release/OrcaSlicer_profile_validator.exe', "$env:RUNNER_TEMP/nsis/Plugins") {
if (Test-Path $extra) { $paths += $extra }
}
./scripts/sign_windows.ps1 -Path $paths
- name: Pack unit tests Win
if: runner.os == 'Windows'
working-directory: ${{ github.workspace }}
@@ -513,8 +574,37 @@ jobs:
- name: Create installer Win
if: runner.os == 'Windows' && !vars.SELF_HOSTED
working-directory: ${{ github.workspace }}/${{ env.BUILD_DIR }}
# Read by scripts/sign_windows.ps1 when CMake wired signing into the installer.
env:
ORCA_SIGN_TOKEN: ${{ steps.codesign_auth.outputs.access_token }}
run: |
cpack -G NSIS
if ($LASTEXITCODE -ne 0) {
# makensis writes its errors, and the signing hook's output, only to this log.
Get-Content _CPack_Packages/*/NSIS/NSISOutput.log -Tail 80
exit 1
}
# Checks the shipped files, the installer, the payload inside it (7-Zip unpacks NSIS
# installers) and the uninstaller a silent install writes.
- name: Verify Windows signatures
if: steps.codesign.outcome == 'success'
timeout-minutes: 20
shell: pwsh
run: |
$paths = @("$env:BUILD_DIR/OrcaSlicer")
$validator = 'build/src/Release/OrcaSlicer_profile_validator.exe'
if (Test-Path $validator) { $paths += $validator }
$installer = Get-ChildItem "$env:BUILD_DIR/OrcaSlicer_Windows_Installer_*.exe" | Select-Object -First 1
if ($installer) {
$payload = Join-Path $env:RUNNER_TEMP 'installer-payload'
& 'C:/Program Files/7-Zip/7z.exe' x -y "-o$payload" $installer.FullName | Out-Null
if ($LASTEXITCODE -ne 0) { throw "7-Zip could not unpack $($installer.Name)." }
$installed = Join-Path $env:RUNNER_TEMP 'installer-test'
Start-Process -Wait -FilePath $installer.FullName -ArgumentList '/S', "/D=$installed"
$paths += $installer.FullName, $payload, (Join-Path $installed 'Uninstall.exe')
}
./scripts/sign_windows.ps1 -Verify -Path $paths
- name: Pack app
if: runner.os == 'Windows'
+27
View File
@@ -1389,6 +1389,33 @@ set(CPACK_PACKAGE_EXECUTABLES "orca-slicer;OrcaSlicer")
set(CPACK_CREATE_DESKTOP_LINKS "orca-slicer")
set (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt) # must also include in install command
# CI release builds Authenticode-sign the installer as makensis builds it: the payload before it is
# compressed, the uninstaller the installer writes, and the installer itself. Only a configure run
# with ORCA_SIGN_KMS_KEY in its environment (build_orca.yml) wires this in; scripts/sign_windows.ps1
# lists what signing needs. The commands go into an included file because CPack writes
# CPACK_NSIS_* values into CPackConfig.cmake unescaped. !include needs a native path, with its
# backslashes doubled for CPackConfig.cmake. PowerShell 7 is preferred: Windows PowerShell started
# under a PowerShell 7 session (CI runs cpack from one) inherits its module path and cannot load
# Get-AuthenticodeSignature.
if (WIN32 AND DEFINED ENV{ORCA_SIGN_KMS_KEY})
find_program(ORCA_SIGN_PWSH pwsh)
if (ORCA_SIGN_PWSH)
set(_orca_sign_shell pwsh)
else ()
set(_orca_sign_shell powershell)
endif ()
set(ORCA_SIGN_COMMAND "${_orca_sign_shell} -NoProfile -ExecutionPolicy Bypass -File \"${CMAKE_SOURCE_DIR}/scripts/sign_windows.ps1\" -Path")
string(CONFIGURE [=[
!system '@ORCA_SIGN_COMMAND@ "${INST_DIR}"' = 0
!uninstfinalize '@ORCA_SIGN_COMMAND@ "%1"' = 0
!finalize '@ORCA_SIGN_COMMAND@ "%1"' = 0
]=] _orca_sign_nsh @ONLY)
file(WRITE "${CMAKE_BINARY_DIR}/sign_windows.nsh" "${_orca_sign_nsh}")
file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/sign_windows.nsh" _orca_sign_nsh_path)
string(REPLACE "\\" "\\\\" _orca_sign_nsh_path "${_orca_sign_nsh_path}")
set(CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS "!include \\\"${_orca_sign_nsh_path}\\\"")
endif ()
set(CPACK_WIX_UPGRADE_GUID "058245e8-20e0-4a95-9ab7-1acfe17ad511")
set(CPACK_GENERATOR NSIS)
include(CPack)
+1 -11
View File
@@ -87,7 +87,7 @@ The [wiki](https://www.orcaslicer.com/wiki) aims to provide a detailed explanati
📥 **[Download the Latest Stable Release](https://github.com/OrcaSlicer/OrcaSlicer/releases/latest)**
Visit our GitHub Releases page for the latest stable version of OrcaSlicer, recommended for most users.
Windows release binaries are code signed; see our [Code signing policy](#code-signing-policy).
Windows and macOS release and nightly builds are code signed.
## Nightly Builds
@@ -245,16 +245,6 @@ OrcaSlicer began in that same spirit, drawing from BambuStudio, PrusaSlicer, and
The OrcaSlicer logo was designed by community member [Justin Levine](https://github.com/jal-co).
# Code Signing Policy
Free code signing provided by [SignPath.io](https://about.signpath.io), certificate by [SignPath Foundation](https://signpath.org).
Windows release binaries are built by GitHub Actions from this repository and signed through the SignPath Foundation program. Every signing request is manually approved.
**Team roles:** [SoftFever](https://github.com/SoftFever) is the committer, reviewer and approver for all signed releases.
**Privacy policy:** See the [OrcaSlicer privacy policy](https://www.orcaslicer.com/privacy-policy/).
# License
- **OrcaSlicer** is licensed under the GNU Affero General Public License, version 3.
+157
View File
@@ -0,0 +1,157 @@
<#
.SYNOPSIS
Authenticode-signs the Windows binaries OrcaSlicer ships, or checks that they are signed.
.DESCRIPTION
Signs with Jsign (https://github.com/ebourg/jsign) and the release key in Google Cloud KMS. The
private key never leaves the HSM: Jsign sends each file's digest to Cloud KMS and builds the
signature from the result and the certificate chain. Every signature is timestamped (RFC 3161),
so it stays valid after the certificate expires.
A directory is searched recursively for .exe, .dll and .pyd files. A file named directly is
handled whatever its name, which covers the temporary files makensis passes for the uninstaller
and the installer. Files that already carry a signature are left alone: they are vendor-signed
redistributables such as the Microsoft runtime, and signing them again would nest a second
signature under the vendor's.
With -Verify nothing is signed. The check fails if any of those files is unsigned or has a
damaged signature, if a file named directly is not signed with the release certificate, or if
a signature made with the release certificate has no timestamp.
build_orca.yml sets the environment. CMakeLists.txt wires the script into the NSIS installer
build when ORCA_SIGN_KMS_KEY is set at configure time.
Environment:
ORCA_SIGN_KMS_KEY Cloud KMS key version:
projects/<p>/locations/<l>/keyRings/<r>/cryptoKeys/<k>/cryptoKeyVersions/<n>
ORCA_SIGN_CERTFILE PEM certificate chain issued for that key, leaf certificate first.
ORCA_SIGN_JSIGN Path of the Jsign jar. Java comes from JAVA_HOME, else from PATH.
ORCA_SIGN_TOKEN OAuth access token allowed to sign with the key. Not needed for -Verify.
Runs under PowerShell 7 and Windows PowerShell 5.1.
.PARAMETER Path
Files and directories to sign or check.
.PARAMETER Verify
Check the signatures instead of signing.
.EXAMPLE
scripts\sign_windows.ps1 -Path build\OrcaSlicer, build\src\Release\OrcaSlicer_profile_validator.exe
#>
param(
[Parameter(Mandatory)] [string[]] $Path,
[switch] $Verify
)
$ErrorActionPreference = 'Stop'
# Sectigo issued the certificate; DigiCert's server takes over if Sectigo's does not answer.
$TimestampUrls = 'http://timestamp.sectigo.com,http://timestamp.digicert.com'
function Require-Env([string] $name) {
$value = [Environment]::GetEnvironmentVariable($name)
if (-not $value) {
throw "$name is not set. See the description in $PSCommandPath."
}
$value
}
# The release certificate is the first one in the chain file.
function Get-ReleaseCertificate([string] $pemFile) {
$pem = Get-Content -LiteralPath $pemFile -Raw
$match = [regex]::Match($pem, '-----BEGIN CERTIFICATE-----\s*([A-Za-z0-9+/=\s]+?)\s*-----END CERTIFICATE-----')
if (-not $match.Success) {
throw "No certificate in $pemFile."
}
$der = [Convert]::FromBase64String(($match.Groups[1].Value -replace '\s', ''))
New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 (, $der)
}
# Each entry is a file and whether it was named directly.
$files = @()
foreach ($item in $Path) {
if (Test-Path -LiteralPath $item -PathType Container) {
$files += Get-ChildItem -LiteralPath $item -Recurse -File |
Where-Object { $_.Extension -in '.exe', '.dll', '.pyd' } |
ForEach-Object { [pscustomobject] @{ Path = $_.FullName; Named = $false } }
} elseif (Test-Path -LiteralPath $item -PathType Leaf) {
$files += [pscustomobject] @{ Path = (Resolve-Path -LiteralPath $item).ProviderPath; Named = $true }
} else {
throw "$item does not exist."
}
}
$certFile = Require-Env 'ORCA_SIGN_CERTFILE'
$release = Get-ReleaseCertificate $certFile
if ($Verify) {
# A release certificate that does not chain to a trusted root (a self-signed test certificate)
# leaves Windows reporting UnknownError for a signature that is otherwise sound.
$chain = New-Object System.Security.Cryptography.X509Certificates.X509Chain
$chain.ChainPolicy.RevocationMode = 'NoCheck'
$trusted = $chain.Build($release)
if (-not $trusted) {
Write-Warning "The release certificate $($release.Subject) does not chain to a trusted root."
}
$problems = @()
$ourCount = 0
foreach ($file in $files) {
$signature = Get-AuthenticodeSignature -LiteralPath $file.Path
$signer = $signature.SignerCertificate
$ours = $signer -and $signer.Thumbprint -eq $release.Thumbprint
if ($ours) {
$ourCount++
}
if (-not $signer) {
$problems += "unsigned: $($file.Path)"
} elseif ($file.Named -and -not $ours) {
$problems += "signed by $($signer.Subject), not the release certificate: $($file.Path)"
} elseif ($ours -and -not $signature.TimeStamperCertificate) {
$problems += "no timestamp: $($file.Path)"
} elseif ($signature.Status -ne 'Valid' -and -not ($ours -and -not $trusted -and $signature.Status -eq 'UnknownError')) {
$problems += "signature status $($signature.Status): $($file.Path)"
}
}
if ($problems) {
$problems | ForEach-Object { Write-Host $_ }
throw "$($problems.Count) of $($files.Count) files failed the signature check."
}
Write-Host "All $($files.Count) files are signed, $ourCount of them with $($release.Subject)."
return
}
$key = Require-Env 'ORCA_SIGN_KMS_KEY'
$jsign = Require-Env 'ORCA_SIGN_JSIGN'
$null = Require-Env 'ORCA_SIGN_TOKEN'
$keyMatch = [regex]::Match($key, '^(projects/[^/]+/locations/[^/]+/keyRings/[^/]+)/cryptoKeys/[^/]+/cryptoKeyVersions/\d+$')
if (-not $keyMatch.Success) {
throw "ORCA_SIGN_KMS_KEY must name a key version, not '$key'."
}
$keyRing = $keyMatch.Groups[1].Value
$unsigned = @($files | Where-Object { -not (Get-AuthenticodeSignature -LiteralPath $_.Path).SignerCertificate } |
ForEach-Object { $_.Path })
Write-Host "$($unsigned.Count) of $($files.Count) files to sign; the rest are already signed."
if (-not $unsigned) {
return
}
$java = 'java'
if ($env:JAVA_HOME) {
$java = Join-Path $env:JAVA_HOME 'bin\java.exe'
}
# Jsign reads the files to sign from a list file, one path per line (UTF-8 without a BOM).
$list = [IO.Path]::GetTempFileName()
try {
[IO.File]::WriteAllLines($list, [string[]] $unsigned)
& $java -jar $jsign --storetype GOOGLECLOUD --keystore $keyRing --alias $key `
--storepass env:ORCA_SIGN_TOKEN --certfile $certFile --alg SHA-256 `
--tsaurl $TimestampUrls --tsmode RFC3161 --tsretries 5 --tsretrywait 15 `
--name OrcaSlicer --url https://www.orcaslicer.com "@$list"
if ($LASTEXITCODE -ne 0) {
throw "Jsign failed with exit code $LASTEXITCODE."
}
} finally {
Remove-Item -LiteralPath $list -ErrorAction SilentlyContinue
}