Repository navigation
fix(installer): honor unsecured certificate flag in installer download steps (#3924) - #218
Samuel Hassine (SamuelHassine) wants to merge 5 commits into
Conversation
…d steps (#3924)
When the OpenAEV platform runs with a self-signed certificate, the
installer and upgrade scripts failed at the download step: the platform
substitutes ${OPENAEV_UNSECURED_CERTIFICATE} into the script templates,
but the download commands (curl on Linux/macOS, Invoke-WebRequest on
Windows) always enforced TLS certificate validation.
- Linux/macOS (12 scripts): add "-k" to the platform download curl
commands only when the substituted flag is "true".
- Windows (6 scripts): when the flag is "true", set
[System.Net.ServicePointManager]::ServerCertificateValidationCallback
around the download and restore the previous callback afterwards.
This works on PowerShell 5.1, which does not support
Invoke-WebRequest -SkipCertificateCheck (PS 6+ only).
TLS validation is bypassed only when the administrator explicitly
enabled the unsecured certificate flag on the platform; the default
path is unchanged.
Fixes OpenAEV-Platform/openaev#3924
There was a problem hiding this comment.
Pull request overview
This PR updates the agent installer/upgrade script templates to honor the platform’s OPENAEV_UNSECURED_CERTIFICATE flag during download steps, allowing installation/upgrade to work when the platform is served with a self-signed (untrusted) TLS certificate.
Changes:
- Linux/macOS: introduce a
curl_insecureflag (-konly when the substituted flag is"true") and pass it to platform downloadcurlcalls. - Windows: when the substituted flag is
"true", temporarily overrideServicePointManager.ServerCertificateValidationCallbackto accept all certificates during download, then restore the previous callback.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| installer/windows/agent-upgrade.ps1 | Temporarily disables TLS validation based on substituted flag for upgrade downloads. |
| installer/windows/agent-upgrade-session-user.ps1 | Same TLS-validation override pattern for session-user upgrade flow. |
| installer/windows/agent-upgrade-service-user.ps1 | Same TLS-validation override pattern for service-user upgrade flow. |
| installer/windows/agent-installer.ps1 | Wraps installer download with conditional TLS-validation bypass and restores in finally. |
| installer/windows/agent-installer-session-user.ps1 | Same conditional TLS bypass for session-user installer download and restore in finally. |
| installer/windows/agent-installer-service-user.ps1 | Same conditional TLS bypass for service-user installer download and restore in finally. |
| installer/macos/agent-upgrade.sh | Adds conditional curl -k usage for upgrade downloads and migration installer download. |
| installer/macos/agent-upgrade-session-user.sh | Adds conditional curl -k usage for session-user upgrade downloads and migration installer download. |
| installer/macos/agent-upgrade-service-user.sh | Adds conditional curl -k usage for service-user upgrade download. |
| installer/macos/agent-installer.sh | Adds conditional curl -k usage for installer download. |
| installer/macos/agent-installer-session-user.sh | Adds conditional curl -k usage for session-user installer download. |
| installer/macos/agent-installer-service-user.sh | Adds conditional curl -k usage for service-user installer download. |
| installer/linux/agent-upgrade.sh | Adds conditional curl -k usage for upgrade downloads and migration installer download. |
| installer/linux/agent-upgrade-session-user.sh | Adds conditional curl -k usage for session-user upgrade downloads and migration installer download. |
| installer/linux/agent-upgrade-service-user.sh | Adds conditional curl -k usage for service-user upgrade download. |
| installer/linux/agent-installer.sh | Adds conditional curl -k usage for installer download. |
| installer/linux/agent-installer-session-user.sh | Adds conditional curl -k usage for session-user installer download. |
| installer/linux/agent-installer-service-user.sh | Adds conditional curl -k usage for service-user installer download. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Romuald Lemesle (RomuDeuxfois)
left a comment
There was a problem hiding this comment.
Linux and macOS look good. Two blocking points:
issue (blocking): On Windows PowerShell 5.1 the bypass doesn't work. The { $true } callback runs on a thread with no runspace, so Invoke-WebRequest still fails ("no Runspace available to run scripts on this thread"). Tried Invoke-PlatformWebRequest as-is against https://self-signed.badssl.com: fails. A compiled callback (Add-Type with a C# method returning true) works.
issue (blocking): The install one-liners shown in the platform (curl -s … | sh, iex (iwr …)) still check the certificate, so a first install on a self-signed platform still fails there. Either fix that side too, or don't close #3924 with this PR.
nitpick: the shell comment says the signature check is "above", it runs below.
…hell 5.1 A script block callback runs on a thread with no runspace on PowerShell 5.1, so Invoke-WebRequest still failed on a self-signed platform. The callback is now a compiled C# method (Add-Type), restored in finally as before. Also fixes the shell comment: the signature check runs after the download.
|
Romuald Lemesle (@RomuDeuxfois) thanks, both points taken in 5a20ca1:
Not run here: a live test against self-signed.badssl.com on Windows PowerShell 5.1 (no Windows runner in my sandbox); CI covers lint and syntax. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #218 +/- ##
==========================================
- Coverage 32.26% 32.05% -0.21%
==========================================
Files 12 12
Lines 685 680 -5
==========================================
- Hits 221 218 -3
+ Misses 464 462 -2
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Summary
When the OpenAEV platform runs with a self-signed certificate, agent installation fails before the agent is even installed: the installer download step always enforces TLS certificate validation, even though the administrator explicitly enabled the platform's unsecured certificate flag. The platform already substitutes
${OPENAEV_UNSECURED_CERTIFICATE}(literaltrue/false) into these script templates for the agent's own config - this PR makes the download commands honor it too.curl_insecurevariable is set to-konly when the substituted flag istrue, and passed to every platform downloadcurl(including the OpenBAS -> OpenAEV migration paths in the upgrade scripts).true, a compiled callback (Add-Type, a C# method returning true) is set as[System.Net.ServicePointManager]::ServerCertificateValidationCallback; a script block callback does not work on PowerShell 5.1 (no runspace on the callback thread). It is set around the download and the previous callback is restored afterwards (infinallyfor the installers). This is PowerShell 5.1 compatible -Invoke-WebRequest -SkipCertificateCheckonly exists on PowerShell 6+.Security posture: TLS validation is bypassed ONLY when the admin explicitly set the unsecured certificate flag on the platform. With the flag
false, the scripts behave exactly as before.Note: the Caldera executor install snippet (which uses
System.Net.WebClient) lives in the platform repository frontend (InstructionSelector.tsx), not in this repository, and is not covered by this PR.Test plan
bash -npasses on all 12 modified.shscripts (POSIX syntax check).[System.Management.Automation.Language.Parser]::ParseFilereports zero errors on all 6 modified.ps1scripts.installer/windows/Run-Lint.ps1(PSScriptAnalyzer): no issues found.trueyieldscurl -sSfL -k <url>, flagfalseyields the exact previous command with no extra argument.openaev.unsecured-certificate=true, then run the generated install command on each OS; the download step should succeed. With the flagfalse, behavior must be unchanged (download fails against an untrusted certificate, as designed).Refs OpenAEV-Platform/openaev#3924 (does not close it: the install one-liners the platform shows,
curl -s ... | shandiex (iwr ...), live in the platform repository and still check the certificate; they are a separate change there).