-
Notifications
You must be signed in to change notification settings - Fork 586
Remove Windows PFX signing fallback #3407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,13 @@ | ||
| # Stop script execution when a non-terminating error occurs | ||
| $ErrorActionPreference = "Stop" | ||
|
|
||
| # Windows code signing defaults to Azure Artifact Signing. Set USE_PFX_CODE_SIGNING to use PFX. | ||
| $usePfx = -not [string]::IsNullOrEmpty($env:USE_PFX_CODE_SIGNING) | ||
| $useAzure = -not $usePfx | ||
|
|
||
| If ($useAzure) { | ||
| Write-Host "--- :windows: Configure Azure Artifact Signing" | ||
| # From the CI toolkit; fails here with diagnostics if Azure credentials are wrong. | ||
| & "setup_azure_trusted_signing.ps1" | ||
| If ($LastExitCode -ne 0) { Exit $LastExitCode } | ||
| } | ||
|
|
||
| If ($usePfx) { | ||
| Write-Host "--- :windows: Configure PFX code signing" | ||
| # From the CI toolkit; materializes certificate.pfx. | ||
| & "setup_windows_code_signing.ps1" | ||
| If ($LastExitCode -ne 0) { Exit $LastExitCode } | ||
|
|
||
| # Read the PFX password from the process env, falling back to the machine-wide env. | ||
| $windowsCertPassword = [System.Environment]::GetEnvironmentVariable('WINDOWS_CODE_SIGNING_CERT_PASSWORD', [System.EnvironmentVariableTarget]::Process) | ||
| If ([string]::IsNullOrEmpty($windowsCertPassword)) { | ||
| $windowsCertPassword = [System.Environment]::GetEnvironmentVariable('WINDOWS_CODE_SIGNING_CERT_PASSWORD', [System.EnvironmentVariableTarget]::Machine) | ||
| } | ||
| If ([string]::IsNullOrEmpty($windowsCertPassword)) { | ||
| Write-Host "[!] WINDOWS_CODE_SIGNING_CERT_PASSWORD is not set in either process or machine environments." | ||
| Exit 1 | ||
| } | ||
|
|
||
| $certPath = (Convert-Path .\certificate.pfx) | ||
| If (-not (Test-Path $certPath)) { | ||
| Write-Host "[!] Certificate file does not exist at given path $certPath." | ||
| Exit 1 | ||
| } | ||
|
|
||
| # Import the cert so electron-builder's certificateSubjectName lookup finds it. | ||
| Import-PfxCertificate -FilePath $certPath -CertStoreLocation Cert:\LocalMachine\Root -Password (ConvertTo-SecureString -String $windowsCertPassword -AsPlainText -Force) | ||
| Write-Host "--- :windows: Configure Azure Artifact Signing" | ||
| # From the CI toolkit; fails here with diagnostics if Azure credentials are wrong. | ||
| & "setup_azure_trusted_signing.ps1" | ||
| If ($LastExitCode -ne 0) { Exit $LastExitCode } | ||
| If ([string]::IsNullOrEmpty($env:SIGNTOOL_PATH)) { | ||
| Write-Host "[!] SIGNTOOL_PATH is not set after Azure Trusted Signing setup." | ||
| Exit 1 | ||
| } | ||
|
|
||
| Write-Host "--- :windows: Installing make" | ||
|
|
@@ -54,21 +26,19 @@ Write-Host "--- :windows: Packaging for Windows" | |
| make package-win32 SKIP_BUILD=true | ||
| If ($LastExitCode -ne 0) { Exit $LastExitCode } | ||
|
|
||
| If ($useAzure) { | ||
| Write-Host "--- :windows: Verify Azure signatures" | ||
| # Every NSIS installer must carry a valid Authenticode signature. The Store AppX is intentionally | ||
| # unsigned (re-signed by the Store), so it is not verified here. | ||
| $exes = Get-ChildItem release\*.exe | ||
| If ($exes.Count -eq 0) { | ||
| Write-Host "[!] No release\*.exe found to verify." | ||
| Exit 1 | ||
| } | ||
| ForEach ($exe in $exes) { | ||
| & $env:SIGNTOOL_PATH verify /pa /v $exe.FullName | ||
| If ($LastExitCode -ne 0) { | ||
| Write-Host "[!] Signature verification failed for $($exe.FullName)" | ||
| Exit $LastExitCode | ||
| } | ||
| Write-Host "--- :windows: Verify Azure signatures" | ||
| # Every NSIS installer must carry a valid Authenticode signature. The Store AppX is intentionally | ||
| # unsigned (re-signed by the Store), so it is not verified here. | ||
| $exes = Get-ChildItem release\*.exe | ||
| If ($exes.Count -eq 0) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fun story of the day: my uncaffeinated brain initially read this as plural of "ex" instead of the plural of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😆 |
||
| Write-Host "[!] No release\*.exe found to verify." | ||
| Exit 1 | ||
| } | ||
| ForEach ($exe in $exes) { | ||
| & $env:SIGNTOOL_PATH verify /pa /v $exe.FullName | ||
| If ($LastExitCode -ne 0) { | ||
| Write-Host "[!] Signature verification failed for $($exe.FullName)" | ||
| Exit $LastExitCode | ||
| } | ||
| Write-Host "All Windows installers verified signed." | ||
| } | ||
| Write-Host "All Windows installers verified signed." | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,14 +139,10 @@ win32: config-release build-if-changed | |
| .PHONY: package | ||
| package: build-if-changed | ||
|
|
||
| # Windows signing: Azure Artifact Signing by default, or PFX when USE_PFX_CODE_SIGNING is set. In | ||
| # Azure mode the NSIS exe signs through the win.sign callback, and the Store AppX builds unsigned — | ||
| # `env -u` removes PFX cert vars so electron-builder skips its built-in /fd-less PFX call. The | ||
| # Store re-signs the AppX regardless. In PFX mode both keep native cert signing, unchanged. | ||
| ifndef USE_PFX_CODE_SIGNING | ||
| # Windows signing: Azure Artifact Signing via the win.sign callback. The Store AppX builds | ||
| # unsigned because Store re-signs the AppX regardless. | ||
| WIN_NSIS_SIGN := -c.win.sign=./scripts/azure-sign.cjs | ||
| APPX_NO_SIGN := env -u CSC_LINK -u CSC_KEY_PASSWORD -u WIN_CSC_LINK -u WIN_CSC_KEY_PASSWORD | ||
|
Comment on lines
+142
to
145
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I considered when removing the test (notice it's in a dedicated commit). My thinking for removing was that a test in that fashion was not valuable because highly tied to implementation rather than behavior. |
||
| endif | ||
|
|
||
| .PHONY: package-win32 | ||
| package-win32: | ||
|
|
||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.