Skip to content

Commit

Permalink
Merge branch 'prometheansacrifice@sign-windows-installer-3' into 'dev'
Browse files Browse the repository at this point in the history
CI: Sign Ligo windows installer with a test developer certificate

See merge request ligolang/ligo!2686
  • Loading branch information
prometheansacrifice committed Jul 15, 2023
2 parents 06bc42e + e38b9e4 commit eb41927
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions .ci/.gitlab-ci-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ esy-windows:
- cp ./LICENSE.md ./windows-installer
- cp ./tools/webide-new/ligo-webide-frontend/ligo-ide/public/favicon.ico ./windows-installer
- cd windows-installer; makensis .\WindowsInstaller.nsi; mv ligo_installer.exe ../ligo_installer.exe ; cd ..
- ./scripts/signInstallerWithTestCertificates.ps1 -Path ./ligo_installer.exe -Password $env:TEST_CERTIFICATE_PASSWORD
- bash -c "esy release || esy release || esy release"
- mv _release platform-windows-x64
artifacts:
Expand Down
36 changes: 36 additions & 0 deletions scripts/signInstallerWithTestCertificates.ps1
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}"
}

0 comments on commit eb41927

Please sign in to comment.