Skip to content

Commit

Permalink
DEBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
vouillon committed Sep 21, 2024
1 parent 7eba5e5 commit 5cc7f80
Showing 1 changed file with 19 additions and 27 deletions.
46 changes: 19 additions & 27 deletions .github/workflows/openssl.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,38 @@
$arch = 'INTEL'
$bits = '64'
$light = $false
$installer = "exe"
$installerType = "exe"
$version = "3.3.2"
$installDir = "$Env:ProgramFiles\OpenSSL"
$installDir = "$env:ProgramFiles\OpenSSL"

# Fetch available installers list
$jsonUrl = 'https://raw.githubusercontent.com/slproweb/opensslhashes/master/win32_openssl_hashes.json'

$installersAvailable = (Invoke-RestMethod $jsonUrl).files
$installerNames = $installersAvailable | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name

$distributor_file_hash = $null
$installerUrl = $null
$installerName = $null

$installersAvailable | Get-Member -MemberType NoteProperty | ForEach-Object {
$key = $_.Name
if(($installersAvailable.$key.light -eq $light) -and ($installersAvailable.$key.arch -eq $arch) -and ($installersAvailable.$key.bits -eq $bits) -and ($installersAvailable.$key.installer -eq $installer) -and ($installersAvailable.$key.basever -eq $version)) {
$installerUrl = $installersAvailable.$key.url
$installerName = $key
$distributor_file_hash = $installersAvailable.$key.sha512
}
$installerHash = $null

foreach ($key in $installerNames) {
$installer = $installersAvailable.$key
if (($installer.light -eq $light) -and ($installer.arch -eq $arch) -and ($installer.bits -eq $bits) -and ($installer.installer -eq $installerType) -and ($installer.basever -eq $version)) {
$installerUrl = $installer.url
$installerHash = $installer.sha512
}
}

# Invoke installation

$installerArgs = '/silent', '/sp-', '/suppressmsgboxes', "/DIR=`"$installDir`""
Install-Binary -Url "$installerUrl" -Name "$installerName" -ArgumentList $installerArgs

#region Supply chain security
Write-Verbose "Performing checksum verification"
$local_file_hash = (Get-FileHash -Path (Join-Path ${env:TEMP} $installerName) -Algorithm SHA512).Hash

if ($local_file_hash -ne $distributor_file_hash) {
Write-Host "hash must be equal to: ${distributor_file_hash}"
Write-Host "actual hash is: ${local_file_hash}"
throw 'Checksum verification failed, please rerun install'
if ($null -eq $installerUrl) {
throw "Installer not found for version $version"
}
#endregion

Install-Binary `
-Url $installerUrl `
-InstallArgs @('/silent', '/sp-', '/suppressmsgboxes', "/DIR=`"$installDir`"") `
-ExpectedSHA512Sum $installerHash

# Update PATH
Add-MachinePathItem "$installDir\bin"
$env:Path = Get-MachinePath
Update-Environment

Invoke-PesterTests -TestFile "Tools" -TestName "OpenSSL"

0 comments on commit 5cc7f80

Please sign in to comment.