This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-website.git
The following commit(s) were added to refs/heads/main by this push:
new 6e5497cb Sync installer scripts with camelops PR #25030 (#1707)
6e5497cb is described below
commit 6e5497cb910193402d933df8d8570b2ed063a927
Author: Adriano Machado <[email protected]>
AuthorDate: Sun Jul 26 01:43:32 2026 -0400
Sync installer scripts with camelops PR #25030 (#1707)
Fixes intermittent Runspace errors in the PowerShell TLS cert validation
callback by replacing the scriptblock with a compiled delegate, resolves
the camel.bat shim path via %~dp0 instead of embedding an absolute path
(fixes non-ASCII install paths), surfaces inner exception details on
download failures, and clears the ServerCertificateValidationCallback on
exit. Adds install.sha256 checksums for the synced scripts.
---
static/install.ps1 | 67 +++++++++++++++++++++++++++++++++++++++------------
static/install.sh | 0
static/install.sha256 | 2 ++
3 files changed, 54 insertions(+), 15 deletions(-)
diff --git a/static/install.ps1 b/static/install.ps1
index a7ef356f..552c426a 100644
--- a/static/install.ps1
+++ b/static/install.ps1
@@ -62,19 +62,44 @@ if ($CaCertPath) {
} else {
$installerCaCert = New-Object
System.Security.Cryptography.X509Certificates.X509Certificate2($CaCertPath)
[System.Net.ServicePointManager]::SecurityProtocol =
[System.Net.SecurityProtocolType]::Tls12
- [System.Net.ServicePointManager]::ServerCertificateValidationCallback
= {
- param($sender, $certificate, $chain, $sslPolicyErrors)
- $verifyChain = New-Object
System.Security.Cryptography.X509Certificates.X509Chain
- $verifyChain.ChainPolicy.ExtraStore.Add($installerCaCert) |
Out-Null
- $verifyChain.ChainPolicy.RevocationMode =
[System.Security.Cryptography.X509Certificates.X509RevocationMode]::NoCheck
- $verifyChain.ChainPolicy.VerificationFlags =
[System.Security.Cryptography.X509Certificates.X509VerificationFlags]::AllowUnknownCertificateAuthority
- $leaf = New-Object
System.Security.Cryptography.X509Certificates.X509Certificate2($certificate)
- if (-not $verifyChain.Build($leaf)) {
- return $false
+
+ # ServerCertificateValidationCallback is invoked by the CLR on
whatever thread performs the TLS
+ # handshake - for HttpWebRequest that is often a
thread-pool/IO-completion-port thread with no
+ # PowerShell Runspace bound to it. A scriptblock delegate then fails
intermittently with "There is
+ # no Runspace available to run scripts in this thread." A compiled
type has no such dependency, so
+ # validate via Add-Type instead of a scriptblock.
+ if (-not ('CamelInstallCertValidator' -as [type])) {
+ Add-Type -TypeDefinition @"
+using System.Net.Security;
+using System.Security.Cryptography.X509Certificates;
+
+public static class CamelInstallCertValidator {
+ public static X509Certificate2 CaCert;
+
+ public static bool Validate(object sender, X509Certificate certificate,
X509Chain chain, SslPolicyErrors sslPolicyErrors) {
+ using (var verifyChain = new X509Chain()) {
+ verifyChain.ChainPolicy.ExtraStore.Add(CaCert);
+ verifyChain.ChainPolicy.RevocationMode =
X509RevocationMode.NoCheck;
+ verifyChain.ChainPolicy.VerificationFlags =
X509VerificationFlags.AllowUnknownCertificateAuthority;
+ var leaf = new X509Certificate2(certificate);
+ if (!verifyChain.Build(leaf)) {
+ return false;
}
- $root =
$verifyChain.ChainElements[$verifyChain.ChainElements.Count - 1].Certificate
- return $root.Thumbprint -eq $installerCaCert.Thumbprint
- }.GetNewClosure()
+ var root =
verifyChain.ChainElements[verifyChain.ChainElements.Count - 1].Certificate;
+ return root.Thumbprint == CaCert.Thumbprint;
+ }
+ }
+}
+"@
+ }
+ [CamelInstallCertValidator]::CaCert = $installerCaCert
+ # Windows PowerShell 5.1 cannot implicitly convert a bare method
reference (PSMethod) to a
+ # custom delegate type - "Cannot convert ... value of type
System.Management.Automation.PSMethod
+ # to type System.Net.Security.RemoteCertificateValidationCallback."
Build the delegate explicitly.
+ [System.Net.ServicePointManager]::ServerCertificateValidationCallback
= [System.Delegate]::CreateDelegate(
+ [System.Net.Security.RemoteCertificateValidationCallback],
+ [CamelInstallCertValidator],
+ 'Validate')
}
}
@@ -88,7 +113,11 @@ function Save-RemoteFile {
Invoke-WebRequest -Uri $Url -OutFile $OutFile -UseBasicParsing |
Out-Null
}
} catch {
- Fail "failed to download $Url"
+ $detail = $_.Exception.Message
+ if ($_.Exception.InnerException) {
+ $detail = "$detail -- $($_.Exception.InnerException.Message)"
+ }
+ Fail "failed to download $Url ($detail)"
}
}
@@ -222,8 +251,13 @@ function Set-CamelShim {
Move-Item -LiteralPath $StagedRoot -Destination $targetDir
New-Item -ItemType Directory -Force -Path $BinDir | Out-Null
- $launcherPath = Join-Path $targetDir 'bin\camel.bat'
- $shimContent = "@echo off`r`ncall `"$launcherPath`" %*`r`nexit /b
%ERRORLEVEL%`r`n"
+ # Resolve the launcher relative to the shim's own location (%~dp0 =
<InstallRoot>\bin\) rather than
+ # embedding the absolute install path as literal text. cmd.exe parses
batch-file bytes in the OEM
+ # code page, so a non-ASCII install path (e.g. a user profile containing
'über') written into the
+ # file as UTF-8 would be misread and 'call' would fail with "The system
cannot find the path
+ # specified." %~dp0 supplies that path as a runtime value instead, which
cmd handles correctly - the
+ # same self-location pattern camel.bat itself uses. Only the version
(validated ASCII) is embedded.
+ $shimContent = "@echo off`r`ncall
`"%~dp0..\cli\versions\$Version\bin\camel.bat`" %*`r`nexit /b %ERRORLEVEL%`r`n"
$tempShim = Join-Path $BinDir ".camel.$PID.tmp.cmd"
# Write without a BOM: Windows PowerShell 5.1's 'Set-Content -Encoding
UTF8' prepends one, which
# cmd.exe treats as part of the first line, breaking '@echo off' and
emitting a stray error.
@@ -328,4 +362,7 @@ try {
if (Test-Path -LiteralPath $stagingRoot) {
Remove-Item -LiteralPath $stagingRoot -Recurse -Force -ErrorAction
SilentlyContinue
}
+ # ServerCertificateValidationCallback is process-wide static state; clear
it even though this
+ # process is about to exit, in case a caller dot-sources install.ps1 into
a longer-lived session.
+ [System.Net.ServicePointManager]::ServerCertificateValidationCallback =
$null
}
diff --git a/static/install.sh b/static/install.sh
old mode 100755
new mode 100644
diff --git a/static/install.sha256 b/static/install.sha256
new file mode 100644
index 00000000..bb029c61
--- /dev/null
+++ b/static/install.sha256
@@ -0,0 +1,2 @@
+install_sh_sha256=b769d73f10867e47a0d06032d879cd0b9f6ca1bf8243ef9689550998048710bb
+install_ps1_sha256=d2e2a152d98ff443d11c4626732a682f20748333747b0a91b028f541458f2d37