Skip to content

Commit e6eb83b

Browse files
committed
chore: cleaned up the commits
1 parent 5b23d1a commit e6eb83b

File tree

4 files changed

+52
-259
lines changed

4 files changed

+52
-259
lines changed

bazel/curl.BUILD

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ CURL_WIN_COPTS = [
145145
"/DCURL_DISABLE_PROXY",
146146
"/DHAVE_LIBZ",
147147
"/DHAVE_ZLIB_H",
148-
"/DUSE_OPENSSL", # UPDATED: Enable OpenSSL interface
149-
"/DHAVE_BORINGSSL", # UPDATED: Explicitly define BoringSSL
148+
"/DUSE_OPENSSL", # Changed: Use OpenSSL/BoringSSL interface
149+
"/DHAVE_BORINGSSL", # Changed: Explicitly define BoringSSL
150150
# Defining _USING_V110_SDK71_ is hackery to defeat curl's incorrect
151151
# detection of what OS releases we can build on with VC 2012. This
152152
# may not be needed (or may have to change) if the WINVER setting
@@ -159,7 +159,7 @@ CURL_WIN_SRCS = [
159159
"lib/inet_ntop.c",
160160
"lib/system_win32.c",
161161
"lib/x509asn1.c",
162-
"lib/vtls/openssl.c", # UPDATED: Use OpenSSL/BoringSSL impl
162+
"lib/vtls/openssl.c", # Changed: Use OpenSSL source instead of schannel.c
163163
"lib/idn_win32.c",
164164
]
165165

@@ -456,7 +456,7 @@ cc_library(
456456
":define-ca-bundle-location",
457457
"@com_github_cares_cares//:ares",
458458
"@zlib",
459-
"@boringssl//:ssl", # UPDATED: Always link BoringSSL (even on Windows)
459+
"@boringssl//:ssl", # Changed: Link BoringSSL on Windows
460460
],
461461
)
462462

@@ -481,6 +481,7 @@ write_file(
481481
"# define BUILDING_LIBCURL 1",
482482
"# define CURL_DISABLE_CRYPTO_AUTH 1",
483483
"# define CURL_DISABLE_DICT 1",
484+
# REMOVED: "# define CURL_DISABLE_FILE 1",
484485
"# define CURL_DISABLE_GOPHER 1",
485486
"# define CURL_DISABLE_IMAP 1",
486487
"# define CURL_DISABLE_LDAP 1",
@@ -491,14 +492,14 @@ write_file(
491492
"# define CURL_DISABLE_TELNET 1",
492493
"# define CURL_DISABLE_TFTP 1",
493494
"# define CURL_PULL_WS2TCPIP_H 1",
494-
"# define USE_OPENSSL 1", // UPDATED: Added
495-
"# define HAVE_BORINGSSL 1", // UPDATED: Added
496-
"# define HAVE_LIBSSL 1", // UPDATED: Added
497-
"# define HAVE_OPENSSL_SSL_H 1", // UPDATED: Added
498-
"# define HAVE_OPENSSL_CRYPTO_H 1",// UPDATED: Added
499-
"# define HAVE_OPENSSL_PEM_H 1", // UPDATED: Added
500-
"# define HAVE_OPENSSL_X509_H 1", // UPDATED: Added
501-
"# define HAVE_OPENSSL_ERR_H 1", // UPDATED: Added
495+
"# define USE_OPENSSL 1", // Changed
496+
"# define HAVE_BORINGSSL 1", // Changed
497+
"# define HAVE_LIBSSL 1", // Changed
498+
"# define HAVE_OPENSSL_SSL_H 1", // Changed
499+
"# define HAVE_OPENSSL_CRYPTO_H 1",// Changed
500+
"# define HAVE_OPENSSL_PEM_H 1", // Changed
501+
"# define HAVE_OPENSSL_X509_H 1", // Changed
502+
"# define HAVE_OPENSSL_ERR_H 1", // Changed
502503
"# define USE_WIN32_IDN 1",
503504
"# define WANT_IDN_PROTOTYPES 1",
504505
"#elif defined(__APPLE__)",
@@ -545,6 +546,7 @@ write_file(
545546
"",
546547
"#if !defined(_WIN32)",
547548
"# define CURL_DISABLE_DICT 1",
549+
# REMOVED: "# define CURL_DISABLE_FILE 1",
548550
"# define CURL_DISABLE_GOPHER 1",
549551
"# define CURL_DISABLE_IMAP 1",
550552
"# define CURL_DISABLE_LDAP 1",

ci/kokoro/windows/builds/bazel.ps1

Lines changed: 19 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# you may not use this file except in compliance with the License.
77
# You may obtain a copy of the License at
88
#
9-
# https://www.apache.org/licenses/LICENSE-2.0
9+
# https://www.apache.org/licenses/LICENSE-2.0
1010
#
1111
# Unless required by applicable law or agreed to in writing, software
1212
# distributed under the License is distributed on an "AS IS" BASIS,
@@ -62,151 +62,43 @@ if ($LastExitCode) {
6262
. ci/kokoro/windows/lib/integration.ps1
6363

6464
function Invoke-REST-Quickstart {
65-
param($bazel_bin)
66-
try {
67-
$executable = Join-Path $bazel_bin "google/cloud/storage/quickstart/quickstart.exe"
68-
Write-Host "Running REST Quickstart, attempting to run: $executable"
69-
if (-not (Test-Path $executable)) {
70-
Write-Host -ForegroundColor Red "Executable not found at the specified path."
71-
Exit 1
72-
}
73-
& $executable "${env:GOOGLE_CLOUD_CPP_STORAGE_TEST_BUCKET_NAME}"
74-
if ($LastExitCode) {
75-
Write-Host -ForegroundColor Red "Execution of (storage/quickstart) failed with exit code ${LastExitCode}."
76-
Exit ${LastExitCode}
77-
}
78-
} catch {
79-
Write-Host -ForegroundColor Red "Caught exception while trying to run storage/quickstart: $_"
80-
Exit 1
65+
bazelisk $common_flags run $build_flags `
66+
//google/cloud/storage/quickstart:quickstart -- `
67+
"${env:GOOGLE_CLOUD_CPP_STORAGE_TEST_BUCKET_NAME}"
68+
if ($LastExitCode) {
69+
Write-Host -ForegroundColor Red "bazel run (storage/quickstart) failed with exit code ${LastExitCode}."
70+
Exit ${LastExitCode}
8171
}
8272
}
8373

8474
function Invoke-gRPC-Quickstart {
85-
param($bazel_bin)
86-
try {
87-
$executable = Join-Path $bazel_bin "google/cloud/pubsub/quickstart/quickstart.exe"
88-
Write-Host "Running gRPC Quickstart, attempting to run: $executable"
89-
if (-not (Test-Path $executable)) {
90-
Write-Host -ForegroundColor Red "Executable not found at the specified path."
91-
Exit 1
92-
}
93-
& $executable "${env:GOOGLE_CLOUD_PROJECT}" "${env:GOOGLE_CLOUD_CPP_PUBSUB_TEST_QUICKSTART_TOPIC}"
94-
if ($LastExitCode) {
95-
Write-Host -ForegroundColor Red "Execution of (pubsub/quickstart) failed with exit code ${LastExitCode}."
96-
Exit ${LastExitCode}
97-
}
98-
} catch {
99-
Write-Host -ForegroundColor Red "Caught exception while trying to run pubsub/quickstart: $_"
100-
Exit 1
75+
bazelisk $common_flags run $build_flags `
76+
//google/cloud/pubsub/quickstart:quickstart -- `
77+
"${env:GOOGLE_CLOUD_PROJECT}" "${env:GOOGLE_CLOUD_CPP_PUBSUB_TEST_QUICKSTART_TOPIC}"
78+
if ($LastExitCode) {
79+
Write-Host -ForegroundColor Red "bazel run (pubsub/quickstart) failed with exit code ${LastExitCode}."
80+
Exit ${LastExitCode}
10181
}
10282
}
10383

10484
if (Test-Integration-Enabled) {
10585
Write-Host "`n$(Get-Date -Format o) Running minimal quickstart prorams"
10686

107-
# 1. Install the certificates
87+
# Install certificates and set up environment variables for BoringSSL
10888
Install-Roots-Pem
109-
110-
# 2. Normalize paths to use Forward Slashes (/)
111-
# This is critical for C++ binaries (BoringSSL/libcurl) to parse paths correctly on Windows.
89+
90+
# BoringSSL prefers forward slashes for paths, even on Windows
11291
$RawRootsPath = Join-Path $env:KOKORO_GFILE_DIR "roots.pem"
11392
$RootsPath = $RawRootsPath -replace '\\', '/'
114-
115-
$RawKeyPath = Join-Path $env:KOKORO_GFILE_DIR "kokoro-run-key.json"
116-
$KeyPath = $RawKeyPath -replace '\\', '/'
93+
$KeyPath = (Join-Path $env:KOKORO_GFILE_DIR "kokoro-run-key.json") -replace '\\', '/'
11794

118-
# 3. Set ALL SSL Environment Variables
119-
# OpenSSL/BoringSSL may look at SSL_CERT_FILE before CURL_CA_BUNDLE
120-
# Use Forward Slashes ($RootsPath) for BoringSSL
12195
$env:GRPC_DEFAULT_SSL_ROOTS_FILE_PATH = $RootsPath
12296
$env:CURL_CA_BUNDLE = $RootsPath
12397
$env:SSL_CERT_FILE = $RootsPath
12498
$env:GOOGLE_APPLICATION_CREDENTIALS = $KeyPath
125-
126-
# 4. Enable Deep Library Logging
127-
$env:GOOGLE_CLOUD_CPP_ENABLE_TRACING="http"
128-
$env:CURL_VERBOSE="1"
129-
130-
# --- DEBUG CHECKS ---
131-
Write-Host -ForegroundColor Cyan "`n--- DEBUG: Environment & File Check ---"
132-
Write-Host "Roots Path: $RootsPath"
133-
134-
Write-Host "`n[Check 1] Environment Variables:"
135-
Get-ChildItem Env: | Where-Object { $_.Name -match 'CURL_|GOOGLE_|GRPC_|SSL_' } | Format-Table -AutoSize | Out-Host
136-
137-
Write-Host "`n[Check 2] File Verify:"
138-
if (Test-Path $RootsPath) {
139-
Write-Host -ForegroundColor Green "File exists."
140-
Get-Item $RootsPath | Select-Object Length, LastWriteTime
141-
} else {
142-
Write-Host -ForegroundColor Red "CRITICAL: File not found at $RootsPath"
143-
}
144-
Write-Host "--- DEBUG END ---`n"
145-
146-
bazelisk $common_flags build $build_flags `
147-
//google/cloud/storage/quickstart:quickstart `
148-
//google/cloud/pubsub/quickstart:quickstart
149-
150-
$bazel_bin = (bazelisk $common_flags info $build_flags bazel-bin).Trim()
151-
# Fix bazel-bin path for PowerShell invocation just in case
152-
$bazel_bin = $bazel_bin.Replace('/', '\')
153-
Write-Host "bazel-bin directory: $bazel_bin"
154-
155-
# --- VERIFICATION EXPERIMENT START ---
156-
Write-Host -ForegroundColor Cyan "`n--- EXPERIMENT: The 'Strip & Retry' Test ---"
157-
158-
# Define paths
159-
$DirtyFile = $RawRootsPath
160-
$CleanFile = Join-Path $env:KOKORO_GFILE_DIR "roots_clean.pem"
161-
$CleanFileForward = $CleanFile -replace '\\', '/'
162-
163-
# Check for the "Poison" (\r)
164-
$text = [System.IO.File]::ReadAllText($DirtyFile)
165-
if ($text.Contains("`r")) {
166-
Write-Host -ForegroundColor Red "[CONFIRMED] 'roots.pem' contains Carriage Returns (\r)."
167-
Write-Host " Attempting to sanitize and run binary..."
168-
169-
# Create the Antidote (Remove all \r)
170-
$cleanText = $text.Replace("`r", "")
171-
[System.IO.File]::WriteAllText($CleanFile, $cleanText)
172-
Write-Host "Created sanitized file: $CleanFileForward"
173-
174-
# Run the Binary against the CLEAN file
175-
Write-Host "`nRunning quickstart.exe using CLEAN file..."
176-
177-
# Temporarily override the env var just for this test
178-
$env:CURL_CA_BUNDLE = $CleanFileForward
179-
$env:SSL_CERT_FILE = $CleanFileForward
180-
$env:GRPC_DEFAULT_SSL_ROOTS_FILE_PATH = $CleanFileForward
181-
182-
# Construct executable path
183-
$QuickstartExe = Join-Path $bazel_bin "google/cloud/storage/quickstart/quickstart.exe"
184-
185-
try {
186-
& $QuickstartExe "${env:GOOGLE_CLOUD_CPP_STORAGE_TEST_BUCKET_NAME}"
187-
if ($LastExitCode -eq 0) {
188-
Write-Host -ForegroundColor Green "`n[SUCCESS] The binary worked with the clean file!"
189-
Write-Host -ForegroundColor Green "CONCLUSION: Carriage Returns were the root cause."
190-
} else {
191-
Write-Host -ForegroundColor Red "`n[FAILURE] The binary still failed ($LastExitCode) even with the clean file."
192-
Write-Host -ForegroundColor Red "CONCLUSION: The issue is NOT carriage returns."
193-
}
194-
} catch {
195-
Write-Host "Execution failed: $_"
196-
}
197-
198-
# Restore Env Vars for standard test flow
199-
$env:CURL_CA_BUNDLE = $RootsPath
200-
$env:SSL_CERT_FILE = $RootsPath
201-
$env:GRPC_DEFAULT_SSL_ROOTS_FILE_PATH = $RootsPath
202-
} else {
203-
Write-Host -ForegroundColor Green "[INFO] 'roots.pem' is already clean (No \r). Experiment skipped."
204-
}
205-
Write-Host "------------------------------------------------"
206-
# --- VERIFICATION EXPERIMENT END ---
20799

208-
Invoke-REST-Quickstart $bazel_bin
209-
Invoke-gRPC-Quickstart $bazel_bin
100+
Invoke-REST-Quickstart
101+
Invoke-gRPC-Quickstart
210102
}
211103

212104
# Shutdown the Bazel server to release any locks

ci/kokoro/windows/lib/integration.ps1

Lines changed: 7 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -26,140 +26,52 @@ function Test-Integration-Enabled {
2626
return $False
2727
}
2828

29-
function Debug-Network {
30-
param([string]$targetUrl)
31-
Write-Host -ForegroundColor Cyan "`n--- NETWORK DEBUG START ($targetUrl) ---"
32-
try {
33-
$uri = New-Object System.Uri($targetUrl)
34-
$hostName = $uri.DnsSafeHost
35-
36-
# 1. DNS Resolution
37-
Write-Host "1. Testing DNS resolution for $hostName..."
38-
$dns = Resolve-DnsName -Name $hostName -ErrorAction SilentlyContinue
39-
if ($dns) { $dns | Format-Table -AutoSize | Out-Host } else { Write-Host -ForegroundColor Red "DNS Resolution FAILED" }
40-
41-
# 2. Basic TCP Connectivity (checking port 443)
42-
Write-Host "`n2. Testing TCP connectivity to $hostName`:443..."
43-
try {
44-
$tcp = Test-NetConnection -ComputerName $hostName -Port 443 -WarningAction SilentlyContinue
45-
if ($tcp.TcpTestSucceeded) { Write-Host "TCP connection SUCCEEDED" } else { Write-Host -ForegroundColor Red "TCP connection FAILED" }
46-
Write-Host "Detailed Info: $($tcp | Out-String)"
47-
} catch {
48-
Write-Host -ForegroundColor Red "Test-NetConnection failed to run: $_"
49-
}
50-
51-
# 3. Proxy Detection
52-
Write-Host "`n3. Checking System Proxy for $targetUrl..."
53-
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
54-
$proxyUri = $proxy.GetProxy($uri)
55-
Write-Host "Effective Proxy: $proxyUri"
56-
Write-Host "Is Bypassed: $($proxy.IsBypassed($uri))"
57-
58-
} catch {
59-
Write-Host -ForegroundColor Red "An error occurred during network debug: $_"
60-
}
61-
Write-Host -ForegroundColor Cyan "--- NETWORK DEBUG END ---`n"
62-
}
63-
6429
function Install-Roots-Pem {
65-
Debug-Network -targetUrl "https://curl.se/ca/cacert.pem"
6630
$RootsPath = "${env:KOKORO_GFILE_DIR}/roots.pem"
6731

6832
ForEach($attempt in (1, 2, 3)) {
6933
Write-Host -ForegroundColor Yellow "`n$(Get-Date -Format o) " `
7034
"Downloading roots.pem [$attempt]"
7135
try {
72-
# 1. Download the Mozilla Bundle to memory string
73-
# We avoid saving to disk immediately to prevent PowerShell from adding CRLF
36+
# 1. Download the Mozilla Bundle
7437
$WebClient = New-Object System.Net.WebClient
7538
$MozillaCerts = $WebClient.DownloadString('https://curl.se/ca/cacert.pem')
7639

77-
# 2. Gather Windows System Certificates
78-
# We check both 'Root' (Trusted Root CAs) and 'CA' (Intermediate CAs)
79-
# as corporate proxies often sign with an Intermediate.
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.
8043
Write-Host "Gathering Windows System Root Certificates..."
8144
$WindowsCerts = ""
8245
$storesToCheck = @("Root", "CA")
8346

8447
foreach ($storeName in $storesToCheck) {
85-
Write-Host -ForegroundColor Cyan "Processing Store: LocalMachine\$storeName"
8648
$certStore = New-Object System.Security.Cryptography.X509Certificates.X509Store -ArgumentList $storeName, "LocalMachine"
8749
$certStore.Open('ReadOnly')
8850

8951
$certStore.Certificates | ForEach-Object {
9052
$cert = $_
91-
Write-Host " Adding: $($cert.Subject)"
92-
93-
# Export to Base64
9453
$b64 = [Convert]::ToBase64String($cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert), 'InsertLineBreaks')
95-
96-
# Construct PEM with explicit Unix Newlines (\n)
9754
$header = "-----BEGIN CERTIFICATE-----"
9855
$footer = "-----END CERTIFICATE-----"
9956
$WindowsCerts += "$header`n$b64`n$footer`n"
10057
}
10158
$certStore.Close()
10259
}
10360

104-
# 3. Write Combined File with Strict UNIX Line Endings (\n)
105-
# We use .NET IO classes to bypass PowerShell's default CRLF behavior.
61+
# 3. Write Combined File with strict Unix Line Endings (\n)
62+
# BoringSSL/gRPC can sometimes have issues with Windows CRLF.
10663
Write-Host "Writing combined roots.pem with Unix LF line endings..."
10764
$FinalContent = $MozillaCerts + "`n" + $WindowsCerts
108-
109-
# Normalize: Replace any Windows \r\n with Unix \n
110-
# This is the CRITICAL FIX for BoringSSL/gRPC which can choke on Carriage Returns (\r)
11165
$FinalContent = $FinalContent -replace "`r`n", "`n"
11266

11367
[System.IO.File]::WriteAllText($RootsPath, $FinalContent, [System.Text.Encoding]::ASCII)
114-
115-
# --- DEBUG START ---
116-
Write-Host -ForegroundColor Cyan "`nDEBUG: Inspecting roots.pem..."
117-
118-
# Check for Seams/Corruption
119-
$corruption = Select-String -Path $RootsPath -Pattern "-----END CERTIFICATE----------BEGIN CERTIFICATE-----"
120-
if ($corruption) {
121-
Write-Host -ForegroundColor Red "FAIL: Found corrupted certificate boundaries!"
122-
} else {
123-
Write-Host -ForegroundColor Green "PASS: No certificate boundary corruption detected."
124-
}
125-
126-
# Check for Carriage Returns (The "BoringSSL Killer")
127-
if ($FinalContent.Contains("`r")) {
128-
Write-Host -ForegroundColor Red "FAIL: File still contains Carriage Returns (\r)!"
129-
} else {
130-
Write-Host -ForegroundColor Green "PASS: File contains strict Unix Line Feeds (\n)."
131-
}
132-
133-
Write-Host -ForegroundColor Cyan "`nDEBUG: Testing SSL connection to GCS..."
13468

135-
# Relax ErrorActionPreference so curl -v stderr doesn't crash the script
136-
$OldEAP = $ErrorActionPreference
137-
$ErrorActionPreference = "Continue"
138-
139-
try {
140-
& curl.exe --version
141-
& curl.exe -v https://storage.googleapis.com --cacert $RootsPath 2>&1 | Out-Host
142-
if ($LastExitCode -ne 0) {
143-
Write-Host -ForegroundColor Red "Curl exited with error code: $LastExitCode"
144-
} else {
145-
Write-Host -ForegroundColor Green "Curl connection test PASSED."
146-
}
147-
} catch {
148-
Write-Host -ForegroundColor Red "Debug curl command failed unexpectedly: $_"
149-
} finally {
150-
$ErrorActionPreference = $OldEAP
151-
}
152-
# --- DEBUG END ---
153-
15469
return
15570
} catch {
15671
Write-Host -ForegroundColor Yellow "`n$(Get-Date -Format o) download/setup error: $_"
157-
if ($attempt -eq 3) {
158-
Debug-Network -targetUrl "https://storage.googleapis.com"
159-
}
16072
}
16173
Start-Sleep -Seconds (60 * $attempt)
16274
}
163-
Write-Host -ForegroundColor Red "cannot download roots.pem file."
75+
Write-Host -ForegroundColor Red "cannot setup roots.pem file."
16476
Exit 1
16577
}

0 commit comments

Comments
 (0)