Skip to content

fix(install): retry npm install with --strict-ssl=false on TLS verification failure (Windows) (#48117)#48416

Open
brokemac79 wants to merge 3 commits intoopenclaw:mainfrom
brokemac79:fix/issue-48117
Open

fix(install): retry npm install with --strict-ssl=false on TLS verification failure (Windows) (#48117)#48416
brokemac79 wants to merge 3 commits intoopenclaw:mainfrom
brokemac79:fix/issue-48117

Conversation

@brokemac79
Copy link
Copy Markdown
Contributor

Summary

Fixes #48117 — Windows install script fails with UNABLE_TO_VERIFY_LEAF_SIGNATURE when running iwr -useb https://openclaw.ai/install.ps1 | iex.

Root Cause

On Windows, npm's default strict SSL verification rejects certificates from intercepting corporate proxies or systems with incomplete/outdated root CA bundles. This throws errors like:

  • UNABLE_TO_VERIFY_LEAF_SIGNATURE
  • CERT_UNTRUSTED
  • SELF_SIGNED_CERT
  • unable to verify the first certificate

This is especially common in enterprise Windows environments.

What the Fix Does

  • Default behavior unchanged — SSL verification remains strict on first attempt
  • If the first npm install fails with a TLS-related error, the script detects the specific error pattern and retries automatically with --strict-ssl=false
  • Displays a clear warning to the user explaining:
    • What went wrong (TLS cert issue)
    • That --strict-ssl=false is being used for this install only
    • How to permanently fix the underlying CA issue (npm config set cafile)
  • If the retry also fails, reports the error and exits

This approach avoids silently disabling SSL globally while still allowing installation on affected Windows machines, with full transparency.

Changes

  • scripts/install.ps1: Modified Install-OpenClawNpm to capture exit code and output from the first npm install attempt, detect TLS error patterns, and retry with --strict-ssl=false if detected.

Testing

Logic verified by code inspection. This is a Windows-only PowerShell path; no automated tests exist for the installer. The TLS detection regex covers the known error strings reported in #48117 and related issues.

AI Disclosure

Fix implemented with Claude claude-sonnet-4-6. Approach reviewed and understood; matches the pattern requested in issue #48117.

…cation failure (Windows) (openclaw#48117)

On Windows, npm install can fail with UNABLE_TO_VERIFY_LEAF_SIGNATURE
or similar TLS errors when corporate proxies or outdated root CAs
intercept HTTPS traffic.

Root cause: npm's default strict SSL verification rejects certificates
from intercepting proxies or systems with incomplete CA bundles, which
is especially common on Windows enterprise environments.

Fix: Keep strict SSL as the default (safe behavior). If the first npm
install attempt fails with a TLS-related error message, automatically
retry with --strict-ssl=false and display a clear warning explaining:
- What went wrong
- That SSL verification is disabled for this install only
- How to permanently fix the underlying CA issue

This avoids disabling SSL globally while still allowing installation
on affected Windows machines, with full transparency to the user.

Testing: Logic verified by code inspection. No automated tests for
PowerShell installer (Windows-only path).

## AI disclosure
Fix implemented with Claude claude-sonnet-4-6. Logic reviewed and understood
by the agent; approach matches the pattern described in issue openclaw#48117.
@brokemac79
Copy link
Copy Markdown
Contributor Author

@codex review

@openclaw-barnacle openclaw-barnacle bot added scripts Repository scripts size: XS labels Mar 16, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 16, 2026

Greptile Summary

This PR adds a TLS-error fallback to the Windows npm installer: if the first npm install fails with a known TLS certificate error (e.g., UNABLE_TO_VERIFY_LEAF_SIGNATURE), it retries with --strict-ssl=false. The implementation correctly switches from the original try/catch (which would not have caught native command failures) to $LASTEXITCODE checking.

Key points:

  • The core logic and TLS pattern matching are correct and cover the known error strings from issue [Bug]: npm error code UNABLE_TO_VERIFT_LEAF_SIGNATURE #48117.
  • Security concern: The --strict-ssl=false retry is automatic — no user confirmation is required. Since a TLS failure is also what an active MITM attack looks like, this path could be triggered by an attacker to cause the installer to download a malicious package over an unverified connection. A Read-Host confirmation prompt before the retry would make the fallback opt-in rather than automatic.
  • Minor UX issue: npm error output is joined with spaces (-join ' ') making error messages hard to read; using newlines would preserve npm's formatted output.

Confidence Score: 3/5

  • Functional fix for the reported issue, but the automatic SSL bypass without user confirmation introduces a security tradeoff that should be addressed before merging.
  • The TLS detection logic and exit-code handling are correct. However, automatically retrying with --strict-ssl=false without prompting the user means a MITM-triggered certificate failure would silently cause the installer to proceed over an unverified connection. This is a meaningful security risk for an installer script, which is a high-trust operation.
  • scripts/install.ps1 — specifically the automatic retry logic at lines 224–247
Prompt To Fix All With AI
This is a comment left during a code review.
Path: scripts/install.ps1
Line: 224-247

Comment:
**Automatic SSL bypass without user confirmation**

When TLS verification fails, this code automatically retries with `--strict-ssl=false` without asking the user. A TLS verification failure is also exactly what would happen during an active MITM attack — meaning an attacker who intercepts the connection could deliberately trigger this code path, causing the installer to silently download and run a malicious package with SSL disabled.

The warning messages are printed, but the retry happens unconditionally. A user confirmation prompt before the retry would significantly reduce this risk:

```powershell
if ($tlsError) {
    Write-Host "" -Level info
    Write-Host "TLS certificate verification failed during npm install." -Level warn
    Write-Host "This is common on Windows when a corporate proxy or outdated root CA" -Level warn
    Write-Host "intercepts HTTPS traffic." -Level warn
    Write-Host "" -Level info
    Write-Host "NOTE: --strict-ssl=false disables SSL certificate verification and can" -Level warn
    Write-Host "expose you to MITM attacks. Only proceed if you trust your network." -Level warn
    Write-Host "" -Level info

    $response = Read-Host "Retry with --strict-ssl=false? [y/N]"
    if ($response -notmatch '^[Yy]$') {
        Write-Host "Aborted. To fix, update your root CA certificates or set:" -Level info
        Write-Host "  npm config set cafile <path-to-your-ca-bundle.pem>" -Level info
        return $false
    }

    $retryOutput = npm install -g $installSpec --no-fund --no-audit --strict-ssl=false 2>&1
    ...
```

Without a confirmation gate, the TLS-bypass path is effectively a denial-of-security rather than a recovery mechanism.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: scripts/install.ps1
Line: 246-250

Comment:
**Error output joined with spaces, hard to read**

Both error paths join multi-line npm output with a single space, which collapses stack traces and error messages into a single unreadable line. Joining with newlines preserves the original formatting and makes errors much easier to diagnose.

```suggestion
        Write-Host "npm install failed even with --strict-ssl=false:`n$($retryOutput -join "`n")" -Level error
        return $false
    }

    Write-Host "npm install failed:`n$($output -join "`n")" -Level error
```

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: ae9b363

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ae9b363ba7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

…r output formatting

- Add interactive Read-Host prompt before retrying npm install with
  --strict-ssl=false to prevent automatic silent SSL bypass (security risk)
- Fix error output joining from -join ' ' to -join "`n" so multi-line
  npm error messages are rendered readably
- Update warning message to remove 'Retrying...' text that implied automatic retry
@brokemac79
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27224b6d61

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

…non-interactive mode

CODEX P2 openclaw#1: Wrap npm install calls in try/catch so CommandNotFoundException
(npm missing from PATH on a partial Node install) returns false cleanly
instead of throwing a terminating error and aborting the script.

CODEX P2 openclaw#2: Gate the TLS-fallback Read-Host prompt behind an interactivity
check ([Environment]::UserInteractive + Console.IsInputRedirected). In CI or
-NonInteractive contexts the prompt is skipped and the function returns false
with actionable guidance, preventing a hang or terminating error in exactly
the enterprise-proxy environments this fix targets.
@brokemac79
Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

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

Labels

scripts Repository scripts size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: npm error code UNABLE_TO_VERIFT_LEAF_SIGNATURE

2 participants