[CmdletBinding()] param() $ErrorActionPreference = 'Stop' Set-StrictMode -Version Latest $build = Join-Path $PSScriptRoot 'build-windows-release.ps1' function Must-Reject([scriptblock]$Action, [string]$Expected) { $rejected = $false try { & $Action } catch { if ($_.Exception.Message -notmatch $Expected) { throw } $rejected = $true } if (-not $rejected) { throw 'Signing preflight accepted an invalid configuration.' } } Must-Reject { & $build -CertificateThumbprint '' -PreflightOnly } 'certificate is required' Must-Reject { & $build -CertificateThumbprint 'not-a-certificate' -AllowUnsigned -PreflightOnly } 'Invalid.*thumbprint' Must-Reject { & $build -CertificateThumbprint ('0' * 40) -AllowUnsigned -PreflightOnly } 'not found' Must-Reject { & $build -CertificateThumbprint '' -AllowUnsigned -TimestampUrl 'file:///tmp/timestamp' -PreflightOnly } 'Timestamp URL' Must-Reject { & $build -CertificateThumbprint '' -AllowUnsigned -TimestampUrl 'https://user:secret@example.invalid' -PreflightOnly } 'Timestamp URL' $result = & $build -CertificateThumbprint '' -AllowUnsigned -PreflightOnly if ($result.signing -or -not $result.unsignedExplicitlyAllowed -or $result.digestAlgorithm -ne 'sha256' -or -not $result.tsp) { throw 'Explicit unsigned preflight returned inconsistent signing metadata.' } Write-Host 'Windows signing preflight: 6 checks passed; no certificates or system settings were changed.'