Improve adding CA certificates on Windows

This commit is contained in:
Shivam Mathur 2021-10-14 22:08:11 +05:30
parent b4593b7df0
commit 383c74bb06
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -161,6 +161,16 @@ Function Get-ExtensionPrerequisites{
return $deps_dir return $deps_dir
} }
# Function to add CA certificates to PHP.
Function Add-PhpCAInfo {
try {
Update-PhpCAInfo -Path $php_dir -Source Curl
} catch {
Add-Log $cross PHP "Could not fetch CA certificate bundle from Curl"
Update-PhpCAInfo -Path $php_dir -Source CurrentUser
}
}
# Function to add PHP extensions. # Function to add PHP extensions.
Function Add-Extension { Function Add-Extension {
Param ( Param (
@ -471,7 +481,6 @@ $current_profile = "$env:TEMP\setup-php.ps1"
$ProgressPreference = 'SilentlyContinue' $ProgressPreference = 'SilentlyContinue'
$jit_versions = '8.[0-9]' $jit_versions = '8.[0-9]'
$nightly_versions = '8.[1-9]' $nightly_versions = '8.[1-9]'
$cert_source='CurrentUser'
$enable_extensions = ('openssl', 'curl', 'mbstring') $enable_extensions = ('openssl', 'curl', 'mbstring')
$arch = 'x64' $arch = 'x64'
@ -487,7 +496,6 @@ if($env:RUNNER -eq 'self-hosted') {
$bin_dir = 'C:\tools\bin' $bin_dir = 'C:\tools\bin'
$php_dir = "$php_dir$version" $php_dir = "$php_dir$version"
$ext_dir = "$php_dir\ext" $ext_dir = "$php_dir\ext"
$cert_source='Curl'
Get-CleanPSProfile >$null 2>&1 Get-CleanPSProfile >$null 2>&1
New-Item $bin_dir -Type Directory -Force > $null 2>&1 New-Item $bin_dir -Type Directory -Force > $null 2>&1
Add-Path -PathItem $bin_dir Add-Path -PathItem $bin_dir
@ -563,7 +571,7 @@ if($version -lt "5.5") {
$enable_extensions += ('opcache') $enable_extensions += ('opcache')
} }
Enable-PhpExtension -Extension $enable_extensions -Path $php_dir Enable-PhpExtension -Extension $enable_extensions -Path $php_dir
Update-PhpCAInfo -Path $php_dir -Source $cert_source Add-PhpCAInfo
Copy-Item -Path $dist\..\src\configs\*.json -Destination $env:RUNNER_TOOL_CACHE Copy-Item -Path $dist\..\src\configs\*.json -Destination $env:RUNNER_TOOL_CACHE
New-Item -ItemType Directory -Path $composer_bin -Force > $null 2>&1 New-Item -ItemType Directory -Path $composer_bin -Force > $null 2>&1
Write-Output "::set-output name=php-version::$($installed.FullVersion)" Write-Output "::set-output name=php-version::$($installed.FullVersion)"