mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 22:16:18 -05:00
ci(windows): sign releases with Azure Artifact Signing and OIDC
This commit is contained in:
7 files changed
+89
-3
No files matched your search
@@ -49,6 +49,10 @@ permissions:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ inputs.architecture == 'arm64' && 'windows-11-arm' || 'windows-2022' }}
|
||||
environment: windows-signing
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
timeout-minutes: 120
|
||||
env:
|
||||
BUILD_ARCHITECTURE: ${{ inputs.architecture }}
|
||||
@@ -59,6 +63,10 @@ jobs:
|
||||
GPGUI_BUILD_VERSION: ${{ inputs.channel == 'snapshot' && inputs.build || '' }}
|
||||
GPGUI_WINDOWS_UPDATE_PUBLIC_KEY: ${{ vars.WINDOWS_UPDATE_PUBLIC_KEY }}
|
||||
GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}
|
||||
AZURE_SIGNING_ENDPOINT: ${{ vars.AZURE_SIGNING_ENDPOINT }}
|
||||
AZURE_SIGNING_ACCOUNT: ${{ vars.AZURE_SIGNING_ACCOUNT }}
|
||||
AZURE_SIGNING_PROFILE: ${{ vars.AZURE_SIGNING_PROFILE }}
|
||||
WINDOWS_SIGNING_PUBLISHER: ${{ vars.WINDOWS_SIGNING_PUBLISHER }}
|
||||
steps:
|
||||
- name: Select native build tools
|
||||
id: native
|
||||
@@ -125,6 +133,15 @@ jobs:
|
||||
& ./source/gp/scripts/build-openconnect-windows.ps1 -MsysRoot $env:MSYS_ROOT -MsysSubsystem ${{ steps.native.outputs.subsystem }} -Prefix $prefix
|
||||
& ./source/gp/scripts/test-openconnect-windows.ps1 -MsysRoot $env:MSYS_ROOT -MsysSubsystem ${{ steps.native.outputs.subsystem }} -Prefix $prefix
|
||||
"OPENCONNECT_WINDOWS_PREFIX=$prefix" >> $env:GITHUB_ENV
|
||||
- name: Log in to Azure with GitHub OIDC
|
||||
uses: azure/login@v3
|
||||
with:
|
||||
client-id: ${{ vars.AZURE_SIGNING_CLIENT_ID }}
|
||||
tenant-id: ${{ vars.AZURE_TENANT_ID }}
|
||||
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
|
||||
- name: Install Microsoft Artifact Signing tooling
|
||||
shell: pwsh
|
||||
run: Install-Module ArtifactSigning -RequiredVersion 0.1.20 -Repository PSGallery -Force -Scope CurrentUser
|
||||
- name: Build and package the matching Windows runtime
|
||||
shell: pwsh
|
||||
env:
|
||||
@@ -134,7 +151,7 @@ jobs:
|
||||
$log = Join-Path $env:RUNNER_TEMP 'windows-package.log'
|
||||
# Compiler diagnostics may contain private GUI source. Keep them on the runner.
|
||||
try {
|
||||
& ./source/gpgui/scripts/build-windows.ps1 -Profile Release `
|
||||
& ./source/gpgui/scripts/build-windows.ps1 -Profile Release -Sign `
|
||||
-NativePrefix $env:OPENCONNECT_WINDOWS_PREFIX -MsysRoot $env:MSYS_ROOT -MsysSubsystem ${{ steps.native.outputs.subsystem }} `
|
||||
-WintunDirectory (Join-Path $env:WINDOWS_BUILD_TOOLS 'wintun') `
|
||||
-MakeNsis (Join-Path ${env:ProgramFiles(x86)} 'NSIS/makensis.exe') `
|
||||
|
||||
@@ -478,6 +478,9 @@ jobs:
|
||||
|
||||
build-windows:
|
||||
needs: validate-inputs
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
if: ${{ (github.event_name == 'workflow_dispatch' && inputs.build_windows) || (startsWith(github.ref, 'refs/tags/') && vars.BUILD_WINDOWS_ON_TAG == 'true') }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
@@ -56,8 +56,25 @@ the current and previous attempt in ProgramData. No updater cache is added.
|
||||
|
||||
The installer never launches the GUI as administrator. Users open GP Connect
|
||||
from the Start menu after completion. User configuration and licensing state
|
||||
are retained during upgrades and uninstall. Authenticode setup is separate;
|
||||
WinSparkle must still verify the installer payload signature before handoff.
|
||||
are retained during upgrades and uninstall. Release builds use Azure Artifact
|
||||
Signing with GitHub OIDC and RFC 3161 timestamps. Application executables,
|
||||
the built OpenConnect DLL, and the generated NSIS uninstaller and installer
|
||||
are signed before checksums and WinSparkle signatures are generated.
|
||||
Vendor DLL signatures are preserved. WinSparkle independently verifies its
|
||||
installer payload signature before handoff.
|
||||
|
||||
The GitHub `windows-signing` environment is trusted by the Entra application
|
||||
`gp-connect-github-signing`. Its only Azure role is Artifact Signing Certificate
|
||||
Profile Signer on `tangramly-signing/certificateProfiles/gp-connect`.
|
||||
Environment deployment policies allow the `release/next` branch and `v*` tags.
|
||||
Repository variables supply `AZURE_SIGNING_CLIENT_ID`, `AZURE_TENANT_ID`,
|
||||
`AZURE_SUBSCRIPTION_ID`, `AZURE_SIGNING_ENDPOINT`, `AZURE_SIGNING_ACCOUNT`,
|
||||
`AZURE_SIGNING_PROFILE`, and `WINDOWS_SIGNING_PUBLISHER`. No Azure client secret
|
||||
or signing private key is stored in GitHub. `build-windows.ps1 -Sign` requires
|
||||
Microsoft's ArtifactSigning PowerShell module 0.1.20 and an Azure CLI login.
|
||||
The build verifies the publisher, certificate trust and timestamp on each signed
|
||||
file. The installer smoke test repeats those checks on the installed runtime
|
||||
and uninstaller before testing removal.
|
||||
|
||||
The Start menu shortcut registers `System.AppUserModel.ID` as `com.yuezk.gpgui`,
|
||||
matching the GUI and native toast sender. Windows uses the shortcut's name and
|
||||
|
||||
@@ -22,6 +22,10 @@ RequestExecutionLevel admin
|
||||
!ifndef DISPLAY_VERSION
|
||||
!define DISPLAY_VERSION "${PRODUCT_VERSION}"
|
||||
!endif
|
||||
!ifdef SIGN_SCRIPT
|
||||
!uninstfinalize 'pwsh -NoLogo -NoProfile -NonInteractive -File "${SIGN_SCRIPT}" -Files "%1"' = 0
|
||||
!finalize 'pwsh -NoLogo -NoProfile -NonInteractive -File "${SIGN_SCRIPT}" -Files "%1"' = 0
|
||||
!endif
|
||||
|
||||
Name "GP Connect"
|
||||
OutFile "${OUTPUT_FILE}"
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
[CmdletBinding()]
|
||||
param([Parameter(Mandatory=$true)][string[]]$Files)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
foreach ($name in @('AZURE_SIGNING_ENDPOINT', 'AZURE_SIGNING_ACCOUNT', 'AZURE_SIGNING_PROFILE', 'WINDOWS_SIGNING_PUBLISHER')) {
|
||||
if (![Environment]::GetEnvironmentVariable($name)) { throw "Missing signing configuration: $name" }
|
||||
}
|
||||
Import-Module ArtifactSigning -RequiredVersion 0.1.20
|
||||
$credentials = @{
|
||||
ExcludeEnvironmentCredential = $true
|
||||
ExcludeWorkloadIdentityCredential = $true
|
||||
ExcludeManagedIdentityCredential = $true
|
||||
ExcludeSharedTokenCacheCredential = $true
|
||||
ExcludeVisualStudioCredential = $true
|
||||
ExcludeVisualStudioCodeCredential = $true
|
||||
ExcludeAzurePowerShellCredential = $true
|
||||
ExcludeAzureDeveloperCliCredential = $true
|
||||
ExcludeInteractiveBrowserCredential = $true
|
||||
}
|
||||
# Azure CLI holds the short-lived GitHub OIDC login; no client secret is used.
|
||||
Invoke-ArtifactSigning -Endpoint $env:AZURE_SIGNING_ENDPOINT `
|
||||
-CodeSigningAccountName $env:AZURE_SIGNING_ACCOUNT -CertificateProfileName $env:AZURE_SIGNING_PROFILE `
|
||||
-Files ($Files -join ',') -FileDigest SHA256 -TimestampDigest SHA256 `
|
||||
-TimestampRfc3161 'http://timestamp.acs.microsoft.com' -Description 'GP Connect' @credentials
|
||||
& (Join-Path $PSScriptRoot 'test-windows-signature.ps1') -Files $Files -Publisher $env:WINDOWS_SIGNING_PUBLISHER
|
||||
@@ -20,6 +20,13 @@ if ($process.ExitCode -ne 0) {
|
||||
}
|
||||
$info = Get-Content (Join-Path $destination 'build-info.json') -Raw | ConvertFrom-Json
|
||||
if ($info.architecture -ne $Architecture -or [string]$info.build_version -ne $Build) { throw 'The installed package identity does not match.' }
|
||||
if ($env:WINDOWS_SIGNING_PUBLISHER) {
|
||||
$signed = @($Installer)
|
||||
foreach ($name in @('gpgui.exe', 'gpauth.exe', 'gpservice.exe', 'gp-posture.exe', 'libopenconnect-5.dll', 'uninstall.exe')) {
|
||||
$signed += Join-Path $destination $name
|
||||
}
|
||||
& (Join-Path $PSScriptRoot 'test-windows-signature.ps1') -Files $signed -Publisher $env:WINDOWS_SIGNING_PUBLISHER
|
||||
}
|
||||
$service = Get-CimInstance Win32_Service -Filter "Name='GPConnect'"
|
||||
if ($service.State -ne 'Running' -or $service.StartMode -ne 'Auto' -or $service.StartName -ne 'LocalSystem') {
|
||||
throw 'The service did not start automatically as LocalSystem.'
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string[]]$Files,
|
||||
[Parameter(Mandatory=$true)][string]$Publisher
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
foreach ($file in $Files) {
|
||||
$signature = Get-AuthenticodeSignature -LiteralPath $file
|
||||
if ($signature.Status -ne 'Valid') { throw "Invalid Authenticode signature: $file ($($signature.Status))" }
|
||||
$name = $signature.SignerCertificate.GetNameInfo([Security.Cryptography.X509Certificates.X509NameType]::SimpleName, $false)
|
||||
if ($name -ne $Publisher) { throw "Unexpected signing publisher for ${file}: $name" }
|
||||
if (!$signature.TimeStamperCertificate) { throw "Missing signature timestamp: $file" }
|
||||
Write-Host "Verified $file (publisher: $name; timestamped)"
|
||||
}
|
||||
Reference in new issue
Block a user