-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-openssl.ps1
65 lines (56 loc) · 2.36 KB
/
install-openssl.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#-----------------------------------------------------------------------------
#
# Copyright (c) 2022, Thierry Lelegard
# BSD-2-Clause license, see LICENSE.txt file
#
# Download and install OpenSSL for Windows.
# See parameters documentation in install-common.ps1.
#
#-----------------------------------------------------------------------------
[CmdletBinding(SupportsShouldProcess=$true)]
param(
[string]$Destination = "",
[switch]$ForceDownload = $false,
[switch]$GitHubActions = $false,
[switch]$NoInstall = $false,
[switch]$NoPause = $false
)
Write-Output "==== OpenSSL download and installation procedure"
. "$PSScriptRoot\install-common.ps1"
# A bit of history: Where to load OpenSSL binaries from?
#
# The packages are built by "slproweb". The binaries are downloadable from
# their Web page at: http://slproweb.com/products/Win32OpenSSL.html
#
# Initially, the HTML for this page was built on server-side. This script
# grabbed the URL content, parse the HTML and extracted the URL of the
# binaries for the latest OpenSSL packages from the "href" of the links.
#
# At some point in 2024, the site changed policy. The Web page is no longer
# built on server-side, but on client-side. The downloaded HTML contains some
# JavaScript which dynamically builds the URL of the binaries for the latest
# OpenSSL binaries. The previous method now finds no valid package URL from
# the downloaded page (a full browser is needed to execute the JavaScript).
# The JavaScript downloads a JSON file which contains all references to
# the OpenSSL binaries. This script now uses the same method: download that
# JSON file and parse it.
$response = Get-HTML "https://github.com/slproweb/opensslhashes/raw/master/win32_openssl_hashes.json"
$config = ConvertFrom-Json $response.Content
# Download and install MSI packages for 32 and 64 bit.
foreach ($bits in @(32, 64)) {
# Get the URL of the MSI installer from the JSON config.
$Url = $config.files | Get-Member | ForEach-Object {
$name = $_.name
$info = $config.files.$($_.name)
if (-not $info.light -and $info.installer -like "msi" -and $info.bits -eq $bits -and $info.arch -like "intel") {
$info.url
}
} | Select-Object -Last 1
if (-not $Url) {
Exit-Script "#### No MSI installer found for Win${bits}"
}
else {
Install-Msi $Url
}
}
Exit-Script