|
4 | 4 | # you may not use this file except in compliance with the License. |
5 | 5 | # You may obtain a copy of the License at |
6 | 6 | # |
7 | | -# https://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
8 | 8 | # |
9 | 9 | # Unless required by applicable law or agreed to in writing, software |
10 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | 14 |
|
15 | 15 | # Helper functions to run the minimal integration tests |
16 | 16 |
|
17 | | -$PROJECT_ROOT = (Get-Item -Path ".\").FullName |
| 17 | +$PROJECT_ROOT = (Get-Item -Path ".\" -Verbose).FullName |
18 | 18 | $integration_tests_config="${PROJECT_ROOT}/ci/etc/integration-tests-config.ps1" |
19 | 19 | . "${integration_tests_config}" |
20 | 20 |
|
21 | 21 | function Test-Integration-Enabled { |
22 | 22 | if ((Test-Path env:KOKORO_GFILE_DIR) -and |
23 | 23 | (Test-Path "${env:KOKORO_GFILE_DIR}/kokoro-run-key.json")) { |
24 | | - return $True |
| 24 | + return $True |
25 | 25 | } |
26 | 26 | return $False |
27 | 27 | } |
28 | 28 |
|
29 | 29 | function Install-Roots-Pem { |
30 | | - $RootsPath = "${env:KOKORO_GFILE_DIR}/roots.pem" |
31 | | - |
| 30 | + Write-Host -ForegroundColor Yellow "`n$(Get-Date -Format o) " ` |
| 31 | + "Downloading roots.pem [$_]" |
32 | 32 | ForEach($attempt in (1, 2, 3)) { |
33 | | - Write-Host -ForegroundColor Yellow "`n$(Get-Date -Format o) " ` |
34 | | - "Downloading roots.pem [$attempt]" |
35 | 33 | try { |
36 | | - # 1. Download the Mozilla Bundle |
37 | | - $WebClient = New-Object System.Net.WebClient |
38 | | - $MozillaCerts = $WebClient.DownloadString('https://curl.se/ca/cacert.pem') |
39 | | - |
40 | | - # 2. Gather Windows System Root Certificates |
41 | | - # This is required because some corporate/cloud environments inspect traffic |
42 | | - # using an intermediate CA present in the system store but not in Mozilla's bundle. |
43 | | - Write-Host "Gathering Windows System Root Certificates..." |
44 | | - $WindowsCerts = "" |
45 | | - $storesToCheck = @("Root", "CA") |
46 | | - |
47 | | - foreach ($storeName in $storesToCheck) { |
48 | | - $certStore = New-Object System.Security.Cryptography.X509Certificates.X509Store -ArgumentList $storeName, "LocalMachine" |
49 | | - $certStore.Open('ReadOnly') |
50 | | - |
51 | | - $certStore.Certificates | ForEach-Object { |
52 | | - $cert = $_ |
53 | | - $b64 = [Convert]::ToBase64String($cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert), 'InsertLineBreaks') |
54 | | - $header = "-----BEGIN CERTIFICATE-----" |
55 | | - $footer = "-----END CERTIFICATE-----" |
56 | | - $WindowsCerts += "$header`n$b64`n$footer`n" |
57 | | - } |
58 | | - $certStore.Close() |
59 | | - } |
60 | | - |
61 | | - # 3. Write Combined File with strict Unix Line Endings (\n) |
62 | | - # BoringSSL/gRPC can sometimes have issues with Windows CRLF. |
63 | | - Write-Host "Writing combined roots.pem with Unix LF line endings..." |
64 | | - $FinalContent = $MozillaCerts + "`n" + $WindowsCerts |
65 | | - $FinalContent = $FinalContent -replace "`r`n", "`n" |
66 | | - |
67 | | - [System.IO.File]::WriteAllText($RootsPath, $FinalContent, [System.Text.Encoding]::ASCII) |
68 | | - |
| 34 | + (New-Object System.Net.WebClient).Downloadfile( |
| 35 | + 'https://pki.google.com/roots.pem', |
| 36 | + "${env:KOKORO_GFILE_DIR}/roots.pem") |
69 | 37 | return |
70 | 38 | } catch { |
71 | | - Write-Host -ForegroundColor Yellow "`n$(Get-Date -Format o) download/setup error: $_" |
| 39 | + Write-Host -ForegroundColor Yellow "`n$(Get-Date -Format o) download error" |
72 | 40 | } |
73 | 41 | Start-Sleep -Seconds (60 * $attempt) |
74 | 42 | } |
75 | | - Write-Host -ForegroundColor Red "cannot setup roots.pem file." |
| 43 | + Write-Host -ForegroundColor Red "cannot download roots.pem file." |
76 | 44 | Exit 1 |
77 | 45 | } |
0 commit comments