Skip to content

fix(apple): Gateway connections fail behind hostname-routed HTTPS proxies - #143648

Merged
vincentkoc merged 5 commits into
openclaw:mainfrom
kramerc:ios-gateway-sni-host
Nov 27, 2026
Merged

vincentkoc merged 5 commits into
openclaw:mainfrom
kramerc:ios-gateway-sni-host

Conversation

@kramerc

@kramerc kramerc commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where iOS users adding a Gateway through a QR setup code would fail to connect when an HTTPS reverse proxy routes requests using an exact hostname match. The same endpoint worked through a dedicated proxy port.

Why This Change Was Made

Gateway WebSocket URLs now omit port 443 for WSS, preventing URLSession from adding an explicit default port to the HTTP Host header. Stored endpoint ports, Gateway identity, cleartext WS ports (including explicit port 80), non-default TLS ports, encoded context paths, and TLS pinning are unchanged. Cleartext ports remain explicit because existing macOS URL canonicalization treats an omitted WS port as 18789.

This replaces the original SNI diagnosis and custom Network.framework WebSocket transport. Live investigation established that HTTP Host matching, not missing SNI, caused this deployment's routing failure. The original URLSession transport and fingerprint probe are restored, retaining their existing authority checks, authentication, cookie, redirect, and WebSocket behavior; the reviewed transport regressions are removed rather than reimplemented.

User Impact

Users can onboard and reconnect to Gateway endpoints behind hostname-matched HTTPS proxies without requiring a separate frontend port or another TLS setting.

Evidence

  • Physical iPhone on iOS 26.6.1: the author tested the revised local app and confirmed QR onboarding and reconnect after relaunch, against the existing proxy configuration.

  • Native before/after proof on macOS and an iOS 26.5 simulator, using the original URLSession pinning session against the same live endpoint (hostname redacted):

    Input Result
    Explicit wss://gateway.example:443/ HTTP 404; no TLS validation failure
    Synthetic setup code decoded through the revised URL builder Stored port remains 443; URL omits the port; HTTP 101 and first WebSocket message received
    Reconnect through the same session using the revised URL HTTP 101 and first WebSocket message received

    The diagnostic sent no Gateway authentication payload and did not log server message contents.

  • Independent IPv4 curl matrix: Host: gateway.example returned HTTP 200 with or without DNS-name SNI; Host: gateway.example:443 returned HTTP 404 with or without DNS-name SNI. Certificate verification was disabled only for the unauthenticated IP-URL/no-SNI diagnostic cases.

  • Regression tests demonstrated default-port failures against the original URL builder. After the fix, 73 tests across DeepLinksSecurityTests, GatewayTLSPinningTests, and GatewayCustomHeadersTests passed, including default/non-default ports, IPv6, retained endpoint ports, and encoded paths.

  • pnpm native:i18n:verify: passed, with no inventory changes needed after removing the custom transport.

  • git diff --check: passed.

  • Repository check:changed for the two-file candidate passed, including app SwiftLint, macOS tooling/process suites, and native schema guards; focused Swift suites and production SwiftLint were rerun after retaining explicit cleartext port 80.

  • Follow-up macOS CI repair updates the primary Gateway replacement test to distinguish a default-port setup link from a profile's supplied explicit port, retaining all credential retirement assertions. Changed-file checks and fresh isolated autoreview, including secret scanning, passed with no P0/P1 findings.

  • Required openclaw/ci-gate passed on 7dec4a7, including successful macos-swift (tests), ios-build (smoke), and android-test-third-party checks (CI run). The earlier macOS URL assertions are repaired. The earlier Android failure did not reproduce: its exact test and all eight tests in SettingsScreensContrastTest passed locally, and fresh CI passed without Android changes.

The native diagnostic proves handshake and reconnect, not a full authenticated app session; physical-device onboarding and relaunch reconnect were separately confirmed by the author. Earlier custom-transport test counts and build evidence have been superseded by this narrower implementation.

Maintainer review — November 27

Reviewed the unchanged published head e3cee63d635abb4fd804d4a7ba6c2b762f4f6921 before the follow-up test consolidation. The production change only omits the serialized WSS default port; endpoint storage, identity, explicit WS ports, TLS pins, credentials, and encoded path bytes retain their existing owners. The current mainline DeepLinks source and shared test suite match the PR fork base byte-for-byte. Current iOS and macOS consumers were also inspected.

The exact-head CI run succeeded on October 30, including iOS screenshots, Android lanes, native i18n, and the required CI gate. This is retained evidence, not a new runtime test. The device/proxy and 73-test results above remain attributed to their original author and revisions.

Local ClawSweeper completed the three-file, five-commit range from 3cd0dd6380a1a1586c6db4574b6fc231eb3367df to the published head with no findings. An independent source review likewise found no change to the security boundaries. No fork code or tests were executed on the operator host.

@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@kramerc
kramerc marked this pull request as ready for review September 10, 2026 03:24
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The shared Apple Gateway URL builder omits default WSS port 443 while preserving endpoint data and other ports.

Example: QR setup supplies wss://gateway.example:443 behind a hostname-matched HTTPS proxy.

  • Before: URLSession sends an explicit :443 in Host and the reported proxy returns HTTP 404.
  • After: The generated URL is wss://gateway.example, and the reported native connection receives HTTP 101 and reconnects successfully.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A small, correct repair with relevant native behavior evidence and focused regression coverage; current-head CI is still running.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied native results exercise setup decoding, the changed URL builder, and the original URLSession pinning transport on macOS and an iOS simulator: explicit :443 fails with HTTP 404, while the normalized URL connects and reconnects with HTTP 101; the author separately confirms physical-iPhone QR onboarding and relaunch reconnect.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Apple users cannot connect through QR setup to an HTTPS proxy that matches the Host header without an explicit default port.
Reason: The fix restores an existing connection flow without adding settings, changing trust policy, or introducing another transport.

Merge readiness

✅ Ready for maintainer review

This PR provides a focused fix for hostname-routed HTTPS proxies that current main still needs; no actionable defects were found, and exact-head CI remains pending.

Priority: P2
Reviewed head: e3cee63d635abb4fd804d4a7ba6c2b762f4f6921

Before merge

None.

Findings

None.

Agent review details

How this fits together

Apple setup and connection controllers convert parsed Gateway endpoints into URLs consumed by the existing URLSession WebSocket transport.

flowchart LR
  A[QR or manual setup] --> B[Gateway deep link parser]
  B --> C[Gateway endpoint URL builder]
  C --> D[Existing URLSession transport]
  D --> E[HTTPS reverse proxy]
  E --> F[Gateway WebSocket]
Loading

Technical review

Best possible solution:

Land this shared URL-builder fix after the current head's required checks complete successfully.

Do we have a high-confidence way to reproduce the issue?

Current-main source emits explicit WSS port 443, and the supplied native comparison identifies the resulting Host-header routing failure; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch is the smallest complete fix: normalize the generated URL in its existing shared owner while retaining endpoint identity, cleartext ports, encoded paths, and transport security.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2ab944733f70.

Provenance checked

  • Shared Gateway WebSocket URL construction changes intended behavior with a stated reason (a320f77: The merged QR-handoff repair moved URL construction to URLComponents with port validation; later pairing work moved construction into GatewayConnectEndpoint and preserved context paths and pins.)
  • macOS primary replacement assertions keeps the original intent (2074e04: The earlier repair keeps Gateway windows and credentials attached to their selected connections; this patch changes only the setup-link URL expectation and retains credential-retirement assertions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit d44f70e adds apps/shared/OpenClawKit/Sources/OpenClawKit/DeepLinks.swift:387 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d44f70eb4bd5; files: apps/shared/OpenClawKit/Sources/OpenClawKit/DeepLinks.swift)
  • Jason (Json): Raw commit 5c6d7c2 adds apps/shared/OpenClawKit/Sources/OpenClawKit/DeepLinks.swift:205 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5c6d7c262227; files: apps/shared/OpenClawKit/Sources/OpenClawKit/DeepLinks.swift)

PR surface

Source +1, Tests +26. Total +27 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 2 32 6 +26
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 34 7 +27

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A concrete connection bug affects deployments using exact-hostname HTTPS proxy routing, with a narrow shared Apple-client fix.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (7 earlier review cycles)
  • reviewed 2026-09-10T03:31:12.141Z sha a823f8b :: needs real behavior proof before merge. :: [P1] Preserve the session authority check in the Network TLS path | [P1] Honor the existing redirect policy during WebSocket upgrade
  • reviewed 2026-09-10T04:51:23.340Z sha c0b5f75 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-10T04:57:03.212Z sha c0b5f75 :: blocked before merge. :: [P1] [P1] Preserve explicit WS port 80 for macOS URL consumers
  • reviewed 2026-09-10T05:03:02.480Z sha f9b0a37 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-10T05:45:54.871Z sha 7dec4a7 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-10T06:09:55.611Z sha 7dec4a7 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-04T16:58:42.835Z sha 7dec4a7 :: needs maintainer review before merge. :: none

Reviewed October 30, 2026, 1:37 AM ET / 05:37 UTC (Revision 8).

@kramerc kramerc changed the title fix(ios): Gateway connections fail behind SNI-routed TLS proxies fix(ios): Gateway connections fail behind hostname-routed HTTPS proxies Sep 10, 2026
@kramerc

kramerc commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated to f9b0a37. The custom transport and fingerprint-probe replacement are removed. Live native proof identified explicit default-port HTTP Host formatting as the cause; the PR now contains only WSS port443 URL normalization and focused tests. Explicit cleartext WS ports remain unchanged, including port80, to preserve the existing macOS canonicalization contract. The body includes before/after native evidence, successful physical-device QR onboarding and relaunch reconnect, 73 passing focused tests, and fresh clean P0/P1 autoreview with macOS consumer context. CI is running on the latest head; prior-head native-i18n, security-fast, and macOS Node lanes passed.

@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 10, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the app: ios App: ios label Sep 10, 2026
@kramerc kramerc changed the title fix(ios): Gateway connections fail behind hostname-routed HTTPS proxies fix(apple): Gateway connections fail behind hostname-routed HTTPS proxies Sep 10, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 10, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Oct 4, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@vincentkoc

Copy link
Copy Markdown
Member

I’m investigating a test-only cleanup that would consolidate the duplicated iOS DeepLinkParserTests into the existing shared DeepLinksSecurityTests, then source-link the canonical suite back into the same iOS app-hosted test target.

The plan preserves every distinct assertion and all of this PR’s default-port regressions. It does not change DeepLinks.swift, URL serialization, or connection behavior. Validation would run the canonical suite through both SwiftPM and the iOS target.

Because both changes touch the shared suite, would you prefer that consolidation wait for this PR’s disposition, or is appending the missing cases independently an acceptable boundary? No parallel source edit has been started.

kramerc commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for checking! My preference is to get this fix merged first, then follow with the consolidation. Appending missing cases independently in a separate PR is fine, provided the existing assertions and default-port regressions remain intact. Please defer moving/removing tests and the iOS source-linking changes until this lands, so we can keep this PR focused and wrap it up.

@vincentkoc vincentkoc self-assigned this Nov 27, 2026
@vincentkoc
vincentkoc merged commit b4047ed into openclaw:main Nov 27, 2026
92 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 27, 2026
…xies (openclaw#143648)

* fix(ios): send gateway websocket SNI

* fix(ios): normalize default ports for gateway proxy routing

* fix(ios): preserve explicit cleartext gateway ports

* test(macos): expect default TLS port normalization for setup links
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…xies (#143648)

* fix(ios): send gateway websocket SNI

* fix(ios): normalize default ports for gateway proxy routing

* fix(ios): preserve explicit cleartext gateway ports

* test(macos): expect default TLS port normalization for setup links

(cherry picked from commit b4047ed)
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…xies (#143648)

* fix(ios): send gateway websocket SNI

* fix(ios): normalize default ports for gateway proxy routing

* fix(ios): preserve explicit cleartext gateway ports

* test(macos): expect default TLS port normalization for setup links

(cherry picked from commit b4047ed)
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants