fix(packaging/windows): the decoded signing key must not outlive the build
windows-host / package (push) Failing after 22s
windows-host / winget-source (push) Skipped
android / android (push) Canceled after 2m11s
apple / swift (push) Canceled after 0s
apple / screenshots (push) Canceled after 0s
arch / build-publish (push) Canceled after 2m28s
ci / rust (push) Canceled after 2m34s
ci / rust-arm64 (push) Canceled after 2m33s
ci / web (push) Canceled after 2m33s
ci / docs-site (push) Canceled after 2m34s
ci / bench (push) Canceled after 1m52s
deb / build-publish (push) Canceled after 0s
deb / build-publish-host (push) Canceled after 16s
deb / build-publish-client-arm64 (push) Canceled after 0s
decky / build-publish (push) Canceled after 8s
docker / build-push (--build-arg FEDORA_VERSION=44, ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora44-rpm) (push) Canceled after 16s
docker / build-push (., web/Dockerfile, punktfunk-web) (push) Canceled after 14s
docker / build-push (ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora-rpm) (push) Canceled after 14s
docker / build-push (ci, ci/rust-ci-noble.Dockerfile, punktfunk-rust-ci-noble) (push) Canceled after 5s
docker / build-push (ci, ci/rust-ci.Dockerfile, punktfunk-rust-ci) (push) Canceled after 5s
docker / build-push (docs-site, docs-site/Dockerfile, punktfunk-docs) (push) Canceled after 4s
docker / build-push-arm64cross (push) Canceled after 0s
docker / deploy-docs (push) Canceled after 0s
rpm / build-publish (43, bazzite, punktfunk-fedora-rpm) (push) Canceled after 14s
rpm / build-publish (44, fedora-44, punktfunk-fedora44-rpm) (push) Canceled after 8s
windows-msix / package (arm64, C:\Users\Public\ffmpeg-arm64, --no-default-features, aarch64-pc-windows-msvc, C:\t-a64) (push) Failing after 3m3s
windows-msix / package (x64, C:\Users\Public\ffmpeg, , x86_64-pc-windows-msvc, C:\t) (push) Failing after 3m14s
windows / build (aarch64-pc-windows-msvc) (push) Successful in 4m58s
windows / build (x86_64-pc-windows-msvc) (push) Successful in 5m50s
windows-host / package (push) Failing after 22s
windows-host / winget-source (push) Skipped
android / android (push) Canceled after 2m11s
apple / swift (push) Canceled after 0s
apple / screenshots (push) Canceled after 0s
arch / build-publish (push) Canceled after 2m28s
ci / rust (push) Canceled after 2m34s
ci / rust-arm64 (push) Canceled after 2m33s
ci / web (push) Canceled after 2m33s
ci / docs-site (push) Canceled after 2m34s
ci / bench (push) Canceled after 1m52s
deb / build-publish (push) Canceled after 0s
deb / build-publish-host (push) Canceled after 16s
deb / build-publish-client-arm64 (push) Canceled after 0s
decky / build-publish (push) Canceled after 8s
docker / build-push (--build-arg FEDORA_VERSION=44, ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora44-rpm) (push) Canceled after 16s
docker / build-push (., web/Dockerfile, punktfunk-web) (push) Canceled after 14s
docker / build-push (ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora-rpm) (push) Canceled after 14s
docker / build-push (ci, ci/rust-ci-noble.Dockerfile, punktfunk-rust-ci-noble) (push) Canceled after 5s
docker / build-push (ci, ci/rust-ci.Dockerfile, punktfunk-rust-ci) (push) Canceled after 5s
docker / build-push (docs-site, docs-site/Dockerfile, punktfunk-docs) (push) Canceled after 4s
docker / build-push-arm64cross (push) Canceled after 0s
docker / deploy-docs (push) Canceled after 0s
rpm / build-publish (43, bazzite, punktfunk-fedora-rpm) (push) Canceled after 14s
rpm / build-publish (44, fedora-44, punktfunk-fedora44-rpm) (push) Canceled after 8s
windows-msix / package (arm64, C:\Users\Public\ffmpeg-arm64, --no-default-features, aarch64-pc-windows-msvc, C:\t-a64) (push) Failing after 3m3s
windows-msix / package (x64, C:\Users\Public\ffmpeg, , x86_64-pc-windows-msvc, C:\t) (push) Failing after 3m14s
windows / build (aarch64-pc-windows-msvc) (push) Successful in 4m58s
windows / build (x86_64-pc-windows-msvc) (push) Successful in 5m50s
Both driver builds base64-decode DRIVER_CERT_PFX_B64 to `driver-signing.pfx` on disk and never delete it. The existing cleanup line only removes the EPHEMERAL cert from the store — it is guarded on $cleanupCert, which is null on exactly the path that writes this file. That was harmless while the cert was a per-build throwaway. It is not harmless now: the key is stable and trusted as a machine root on every box that installs punktfunk, so a .pfx sitting in a build directory is a standing credential on the machine that runs build jobs. Every windows-host build would have left one. Adds Remove-SigningPfx, called after the last signing step and from a script-scope trap so a mid-build failure doesn't strand the key either. Verified on the runner: both scripts parse, the key is gone on the success path, gone on the failure path, and a second call is a no-op. The `break` in that trap is explicitness, not correctness. I first wrote it claiming a bare trap would resume past the error and let a build finish with unsigned drivers; measuring on the runner disproved that — bare and break behave identically (exit 1, no resumption) for `throw` at script scope, `throw` inside a function, and a cmdlet error under EAP=Stop. Kept, with the comment saying what was actually measured rather than what I assumed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -35,6 +35,23 @@ $ErrorActionPreference = 'Stop'
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
$PSNativeCommandUseErrorActionPreference = $false
|
||||
|
||||
# The decoded signing key must not outlive this script. It is a STABLE key now — trusted as a
|
||||
# machine root on every box that installs punktfunk — so a .pfx left behind in a build directory is
|
||||
# a standing credential on a machine that runs build jobs, not the throwaway it used to be. A
|
||||
# script-scope trap covers the failure paths; Remove-SigningPfx is also called on the way out.
|
||||
$script:ShredPfx = $null
|
||||
function Remove-SigningPfx {
|
||||
if ($script:ShredPfx -and (Test-Path $script:ShredPfx)) {
|
||||
Remove-Item $script:ShredPfx -Force -ErrorAction SilentlyContinue
|
||||
$script:ShredPfx = $null
|
||||
}
|
||||
}
|
||||
# `break` is for explicitness, not correctness: measured on the runner, a bare trap and
|
||||
# trap+break behave identically here (exit 1, no resumption) for `throw` at script scope,
|
||||
# `throw` inside a function, and a cmdlet error under EAP=Stop. Kept because it states the
|
||||
# intent — shred, then re-throw — instead of relying on a default that is easy to misread.
|
||||
trap { Remove-SigningPfx; break }
|
||||
|
||||
$DriversDir = (Resolve-Path $DriversDir).Path
|
||||
$clear = Join-Path $PSScriptRoot 'clear-force-integrity.ps1'
|
||||
|
||||
@@ -99,6 +116,7 @@ $cleanupCert = $null
|
||||
if ($CertPfxB64) {
|
||||
Write-Host '==> signing with supplied driver cert (DRIVER_CERT_PFX_B64)'
|
||||
$pfx = Join-Path (Split-Path -Parent $Out) 'driver-signing.pfx'
|
||||
$script:ShredPfx = $pfx
|
||||
[IO.File]::WriteAllBytes($pfx, [Convert]::FromBase64String($CertPfxB64))
|
||||
$sec = if ($CertPassword) { ConvertTo-SecureString $CertPassword -AsPlainText -Force } else { $null }
|
||||
$signArgs = @('/f', $pfx); if ($CertPassword) { $signArgs += @('/p', $CertPassword) }
|
||||
@@ -145,6 +163,7 @@ foreach ($d in $drivers) {
|
||||
# --- 6. one shared public .cer ----------------------------------------------------------------
|
||||
Export-Certificate -Cert $pubForCer -FilePath (Join-Path $Out 'punktfunk-driver.cer') | Out-Null
|
||||
if ($cleanupCert) { Remove-Item "Cert:\CurrentUser\My\$($cleanupCert.Thumbprint)" -Force -ErrorAction SilentlyContinue }
|
||||
Remove-SigningPfx
|
||||
|
||||
Write-Host "==> built + signed gamepad drivers DriverVer=$DriverVer -> $Out"
|
||||
Get-ChildItem $Out -File | ForEach-Object { " $($_.Name) ($($_.Length) bytes)" }
|
||||
|
||||
@@ -37,6 +37,23 @@ $ErrorActionPreference = 'Stop'
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
$PSNativeCommandUseErrorActionPreference = $false
|
||||
|
||||
# The decoded signing key must not outlive this script. It is a STABLE key now — trusted as a
|
||||
# machine root on every box that installs punktfunk — so a .pfx left behind in a build directory is
|
||||
# a standing credential on a machine that runs build jobs, not the throwaway it used to be. A
|
||||
# script-scope trap covers the failure paths; Remove-SigningPfx is also called on the way out.
|
||||
$script:ShredPfx = $null
|
||||
function Remove-SigningPfx {
|
||||
if ($script:ShredPfx -and (Test-Path $script:ShredPfx)) {
|
||||
Remove-Item $script:ShredPfx -Force -ErrorAction SilentlyContinue
|
||||
$script:ShredPfx = $null
|
||||
}
|
||||
}
|
||||
# `break` is for explicitness, not correctness: measured on the runner, a bare trap and
|
||||
# trap+break behave identically here (exit 1, no resumption) for `throw` at script scope,
|
||||
# `throw` inside a function, and a cmdlet error under EAP=Stop. Kept because it states the
|
||||
# intent — shred, then re-throw — instead of relying on a default that is easy to misread.
|
||||
trap { Remove-SigningPfx; break }
|
||||
|
||||
$DriversDir = (Resolve-Path $DriversDir).Path
|
||||
$inx = Join-Path $DriversDir 'pf-vdisplay\pf_vdisplay.inx'
|
||||
$clear = Join-Path $PSScriptRoot 'clear-force-integrity.ps1'
|
||||
@@ -96,6 +113,7 @@ $cleanupCert = $null
|
||||
if ($CertPfxB64) {
|
||||
Write-Host '==> signing with supplied driver cert (DRIVER_CERT_PFX_B64)'
|
||||
$pfx = Join-Path $Out '..\driver-signing.pfx'
|
||||
$script:ShredPfx = $pfx
|
||||
[IO.File]::WriteAllBytes($pfx, [Convert]::FromBase64String($CertPfxB64))
|
||||
$sec = if ($CertPassword) { ConvertTo-SecureString $CertPassword -AsPlainText -Force } else { $null }
|
||||
$signArgs = @('/f', $pfx); if ($CertPassword) { $signArgs += @('/p', $CertPassword) }
|
||||
@@ -138,6 +156,7 @@ if (-not (Test-Path $sCat)) { throw "Inf2Cat did not produce $sCat" }
|
||||
if ($LASTEXITCODE -ne 0) { throw "signtool sign (cat) failed ($LASTEXITCODE)" }
|
||||
Export-Certificate -Cert $pubForCer -FilePath $sCer | Out-Null
|
||||
if ($cleanupCert) { Remove-Item "Cert:\CurrentUser\My\$($cleanupCert.Thumbprint)" -Force -ErrorAction SilentlyContinue }
|
||||
Remove-SigningPfx
|
||||
|
||||
# --- 5. guard: assert the freshly-built catalog covers the inf + dll ---------------------------
|
||||
# Built-from-source can't drift, but this catches a botched stampinf/Inf2Cat ordering. Test-FileCatalog
|
||||
|
||||
Reference in New Issue
Block a user