-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'prometheansacrifice@sign-windows-installer-3' into 'dev'
CI: Sign Ligo windows installer with a test developer certificate See merge request ligolang/ligo!2686
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
param([switch]$Elevated, $Path, $Password) | ||
|
||
function Test-Admin { | ||
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent()) | ||
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) | ||
} | ||
|
||
if ((Test-Admin) -eq $false) { | ||
if ($elevated) { | ||
# tried to elevate, did not work, aborting | ||
echo "Could not elevate" | ||
exit 1 | ||
} else { | ||
Start-Process powershell.exe -Verb RunAs -ArgumentList ("-noprofile -file {0} -Password ${env:TEST_CERTIFICATE_PASSWORD} -Path $(Resolve-Path $Path) -elevated" -f ($myinvocation.MyCommand.Definition)) | ||
} | ||
exit | ||
} | ||
|
||
|
||
$TestCertificatePassword = "default" | ||
if ($env:TEST_CERTIFICATE_PASSWORD) { | ||
$TestCertificatePassword = $env:TEST_CERTIFICATE_PASSWORD | ||
} | ||
if ($Password) { | ||
$TestCertificatePassword = $Password | ||
} | ||
|
||
$cert = New-SelfSignedCertificate -DnsName ligolang -CertStoreLocation cert:\LocalMachine\My -type CodeSigning | ||
$pwd = ConvertTo-SecureString -String $TestCertificatePassword -Force -AsPlainText | ||
Export-PfxCertificate -cert $cert -FilePath ligolang-certs.pfx -Password $pwd | ||
$env:PATH = $env:PATH + ';C:\Program Files (x86)\Windows Kits\10\App Certification Kit;C:\Program Files (x86)\Windows Kits\10\bin\x64' | ||
signtool.exe sign /a /f ligolang-certs.pfx /p $TestCertificatePassword /fd SHA256 $Path | ||
|
||
if (!$?) { | ||
echo "Could not sign ${Path}" | ||
} |