Skip to content

fix(installer): honor unsecured certificate flag in installer download steps (#3924) - #218

Open
Samuel Hassine (SamuelHassine) wants to merge 5 commits into
mainfrom
issue/3924-installer-self-signed
Open

Samuel Hassine (SamuelHassine) wants to merge 5 commits into
mainfrom
issue/3924-installer-self-signed

Conversation

@SamuelHassine

@SamuelHassine Samuel Hassine (SamuelHassine) commented Aug 11, 2026 •

Copy link
Copy Markdown
Member

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} (literal true/false) into these script templates for the agent's own config - this PR makes the download commands honor it too.

  • Linux/macOS (12 scripts: installer + upgrade, service / service-user / session-user): a curl_insecure variable is set to -k only when the substituted flag is true, and passed to every platform download curl (including the OpenBAS -> OpenAEV migration paths in the upgrade scripts).
  • Windows (6 scripts: installer + upgrade, service / service-user / session-user): when the flag is 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 (in finally for the installers). This is PowerShell 5.1 compatible - Invoke-WebRequest -SkipCertificateCheck only 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 -n passes on all 12 modified .sh scripts (POSIX syntax check).
  • [System.Management.Automation.Language.Parser]::ParseFile reports zero errors on all 6 modified .ps1 scripts.
  • Repo lint installer/windows/Run-Lint.ps1 (PSScriptAnalyzer): no issues found.
  • Simulated the substituted gating logic: flag true yields curl -sSfL -k <url>, flag false yields the exact previous command with no extra argument.
  • Manual test suggestion: deploy a platform with a self-signed certificate and openaev.unsecured-certificate=true, then run the generated install command on each OS; the download step should succeed. With the flag false, 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 ... | sh and iex (iwr ...), live in the platform repository and still check the certificate; they are a separate change there).

…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
Copilot AI lite review requested due to automatic review settings August 11, 2026 12:55
@github-actions github-actions Bot added the filigran team Item from the Filigran team. label Aug 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_insecure flag (-k only when the substituted flag is "true") and pass it to platform download curl calls.
  • Windows: when the substituted flag is "true", temporarily override ServicePointManager.ServerCertificateValidationCallback to 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.

Comment thread installer/windows/agent-upgrade.ps1 Resolved

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@SamuelHassine

Copy link
Copy Markdown
Member Author

Romuald Lemesle (@RomuDeuxfois) thanks, both points taken in 5a20ca1:

  • PowerShell 5.1 callback: the six Windows scripts now set a compiled callback (Add-Type, a static C# method returning true, added once per session) instead of the { $true } script block, still restored in finally.
  • Install one-liners: this PR no longer closes openaev#3924; the body now says Refs and names the platform-side one-liners as a separate change.
  • Nitpick: the shell comment now says the signature check runs after the download.

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

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 32.05%. Comparing base (e58d9ca) to head (5a20ca1).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
agent 32.05% <ø> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

filigran team Item from the Filigran team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants