infra: HSTS on coa-infra.matou.nz breaks desktop org setup — raw-port KERIA fetches get upgraded to https (Setup Failed: Failed to fetch) #141

Closed
opened 2026-09-07 01:26:31 +00:00 by ben · 2 comments
Owner

Summary

Every COA desktop app built against the shared backend fails at Set up → Launch App with Setup Failed — Failed to fetch. Reproduced 2026-09-07 with the fresh ngati-example build 2 (ngati-example-0.6.8-linux.AppImage, coa-builds run 34072026536, matou-app v0.6.8) on Linux, tenant https://coa-infra.matou.nz/ngati-example (configured: false).

Root cause (proven)

coa-infra.matou.nz is served by Caddy with the mds security_headers snippet, which sends
Strict-Transport-Security: max-age=3600; includeSubDomains; preload. The app's first request is https://coa-infra.matou.nz/ngati-example/api/client-config, so Chromium records HSTS for the host. The client config then points KERIA/boot/CESR/schema at plain-HTTP raw ports on the same host name (http://coa-infra.matou.nz:5901, :5903, :5902, :9723, witnesses :7642–7647). HSTS upgrades those fetches to https://coa-infra.matou.nz:5901; the listener speaks plain HTTP, the TLS handshake fails and the fetch dies (net::ERR_CONNECTION_CLOSED).

Evidence from the running app (Electron main log):

[KERIClient] Attempting to connect to existing agent...
ERROR:net/socket/ssl_client_socket_impl.cc:916] handshake failed; returned -1, SSL error code 1, net_error -100
[KERIClient] Connect error: Failed to fetch
[OrgSetup] Error: TypeError: Failed to fetch  (at KERIClient.connect → initialize → setupOrg)

Probe from inside the renderer (same session):

http://coa-infra.matou.nz:5901/  → ERR Failed to fetch
http://143.198.134.168:5901/     → 401   (plain HTTP by IP works: HSTS is per host name)
http://coa-infra.matou.nz:9723/  → ERR Failed to fetch
http://143.198.134.168:9723/     → 200

curl from the laptop reaches every raw port fine (401/405/200), and KERIA answers CORS preflight with Access-Control-Allow-Origin: * — this is not a firewall or CORS problem. matou.nz is not on the HSTS preload list (hstspreload.org status unknown), so the header is the only source. The mds template is roles/coa_shared/templates/coa-infra.caddy.j2 (import security_headers); the snippet is in roles/caddy/templates/Caddyfile.j2.

This masked nothing in phase 3: the ngati-example proof never ran /setup (tenant dir is still empty), and mobile uses the loopback proxy (matou-app#368), so only desktop hits KERIA by host name from Chromium.

Fix options (Ben rules — shared-infra change)

  1. Stopgap (small, reversible): drop HSTS for the coa-infra site block only (a security_headers_no_hsts snippet, or header -Strict-Transport-Security after the import). Clients recover once the cached entry expires (max-age is 1 h) or userData is cleared. Keeps the phase-3 raw-port design as is.
  2. Proper: front KERIA admin/boot/CESR, the schema server and the witnesses with TLS (Caddy paths or sub-hosts) and have the tenant config server emit https:// URLs in coa mode (matou-infrastructure config server + witness location records). Then HSTS can stay.

Either way docs/GOTCHAS.md needs the entry with the fix commit.

Acceptance

Fresh ~/.config/Ngati Example, launch ngati-example-0.6.8-linux.AppImage, fill admin name, Launch App → progresses past "Connecting to KERIA…" to the recovery-phrase screen; GET https://coa-infra.matou.nz/ngati-example/api/health reports configured: true.

  • #139 (anonymous download 404) — the poster's download links; independent.
  • any-sync node-1 on coa-shared is crash-looping (separate ticket) — will bite the next step of setup (community space creation) once this is fixed.
## Summary Every COA desktop app built against the shared backend fails at **Set up → Launch App** with `Setup Failed — Failed to fetch`. Reproduced 2026-09-07 with the fresh `ngati-example` build 2 (`ngati-example-0.6.8-linux.AppImage`, coa-builds run 34072026536, matou-app v0.6.8) on Linux, tenant `https://coa-infra.matou.nz/ngati-example` (`configured: false`). ## Root cause (proven) `coa-infra.matou.nz` is served by Caddy with the mds `security_headers` snippet, which sends `Strict-Transport-Security: max-age=3600; includeSubDomains; preload`. The app's first request is `https://coa-infra.matou.nz/ngati-example/api/client-config`, so Chromium records HSTS for the host. The client config then points KERIA/boot/CESR/schema at **plain-HTTP raw ports on the same host name** (`http://coa-infra.matou.nz:5901`, `:5903`, `:5902`, `:9723`, witnesses `:7642–7647`). HSTS upgrades those fetches to `https://coa-infra.matou.nz:5901`; the listener speaks plain HTTP, the TLS handshake fails and the fetch dies (`net::ERR_CONNECTION_CLOSED`). Evidence from the running app (Electron main log): ``` [KERIClient] Attempting to connect to existing agent... ERROR:net/socket/ssl_client_socket_impl.cc:916] handshake failed; returned -1, SSL error code 1, net_error -100 [KERIClient] Connect error: Failed to fetch [OrgSetup] Error: TypeError: Failed to fetch (at KERIClient.connect → initialize → setupOrg) ``` Probe from inside the renderer (same session): ``` http://coa-infra.matou.nz:5901/ → ERR Failed to fetch http://143.198.134.168:5901/ → 401 (plain HTTP by IP works: HSTS is per host name) http://coa-infra.matou.nz:9723/ → ERR Failed to fetch http://143.198.134.168:9723/ → 200 ``` `curl` from the laptop reaches every raw port fine (401/405/200), and KERIA answers CORS preflight with `Access-Control-Allow-Origin: *` — this is not a firewall or CORS problem. `matou.nz` is **not** on the HSTS preload list (`hstspreload.org` status `unknown`), so the header is the only source. The mds template is `roles/coa_shared/templates/coa-infra.caddy.j2` (`import security_headers`); the snippet is in `roles/caddy/templates/Caddyfile.j2`. This masked nothing in phase 3: the ngati-example proof never ran `/setup` (tenant dir is still empty), and mobile uses the loopback proxy (matou-app#368), so only desktop hits KERIA by host name from Chromium. ## Fix options (Ben rules — shared-infra change) 1. **Stopgap (small, reversible):** drop HSTS for the `coa-infra` site block only (a `security_headers_no_hsts` snippet, or `header -Strict-Transport-Security` after the import). Clients recover once the cached entry expires (max-age is 1 h) or userData is cleared. Keeps the phase-3 raw-port design as is. 2. **Proper:** front KERIA admin/boot/CESR, the schema server and the witnesses with TLS (Caddy paths or sub-hosts) and have the tenant config server emit `https://` URLs in coa mode (matou-infrastructure config server + witness location records). Then HSTS can stay. Either way `docs/GOTCHAS.md` needs the entry with the fix commit. ## Acceptance Fresh `~/.config/Ngati Example`, launch `ngati-example-0.6.8-linux.AppImage`, fill admin name, **Launch App** → progresses past "Connecting to KERIA…" to the recovery-phrase screen; `GET https://coa-infra.matou.nz/ngati-example/api/health` reports `configured: true`. ## Related - #139 (anonymous download 404) — the poster's download links; independent. - any-sync `node-1` on coa-shared is crash-looping (separate ticket) — will bite the *next* step of setup (community space creation) once this is fixed.
Author
Owner

Ben ruled option 2 (the proper fix). Built as three PRs, ready for merge + deploy in this order:

  1. matou-infrastructure PR #18 (issue #17) — config-server.py PUBLIC_BASE_URL mints the proxied layout (/keria/admin, /keria/boot, /keria/cesr, /schema, /witness/<name>, config server at the root); keri/docker-compose.coa.yml binds every HTTP service to loopback in coa mode (Docker-published ports bypass ufw — 5904 answers from the internet today); generate-env.sh coa defaults the base to CONFIG_PUBLIC_URL. 18 new + 55 existing config-server checks green. Branch also pushed to GitLab as infra/coa-tls-front so the host can fetch the pin before the mirror.
  2. matou-distributed-servers PR #16 (issue #15, ADR 0003) — coa-infra.caddy.j2 handle_path ladder (prefix stripped: signify-ts signs the KERIA-relative path), PUBLIC_BASE_URL + EXTERNAL_SCHEME=https into the env generator, pin coa_shared_infra_ref = d59951a0f6cb… (PR #18 head), ufw allow rules for 5901–5903/7642–7647/9723 deleted, post-reload https probes of the ladder.
  3. matou-app PR #448 (issue #447) — mobile loopback proxy keeps the upstream path prefix; registrationResolve stops using .origin; getKeriaUrls() strips trailing slashes. Desktop needs nothing from this PR.

Deploy (needs your seat — the session's harness blocks PR merges and host changes):

# merge PR #18 on Forgejo, then mirror: git push origin forgejo/main:main   (in matou-infrastructure)
# merge PR #16 on Forgejo, then from the mds checkout:
ansible-playbook playbooks/host.yml -l matou -t coa_shared --check --diff
ansible-playbook playbooks/host.yml -l matou -t coa_shared
git push gitlab origin/main:main

Expected on the host: keri containers recreated with 127.0.0.1: bindings, four https probes green, GET https://coa-infra.matou.nz/ngati-example/api/client-config showing https://coa-infra.matou.nz/keria/admin etc. Then I re-run the ngati-example 0.6.8 AppImage setup drive (no rebuild needed: the app reads the URLs at runtime).

Ben ruled option 2 (the proper fix). Built as three PRs, ready for merge + deploy in this order: 1. **matou-infrastructure PR #18** (issue #17) — `config-server.py` `PUBLIC_BASE_URL` mints the *proxied layout* (`/keria/admin`, `/keria/boot`, `/keria/cesr`, `/schema`, `/witness/<name>`, config server at the root); `keri/docker-compose.coa.yml` binds every HTTP service to loopback in coa mode (Docker-published ports bypass ufw — 5904 answers from the internet today); `generate-env.sh coa` defaults the base to `CONFIG_PUBLIC_URL`. 18 new + 55 existing config-server checks green. Branch also pushed to GitLab as `infra/coa-tls-front` so the host can fetch the pin before the mirror. 2. **matou-distributed-servers PR #16** (issue #15, ADR 0003) — `coa-infra.caddy.j2` `handle_path` ladder (prefix stripped: signify-ts signs the KERIA-relative path), `PUBLIC_BASE_URL` + `EXTERNAL_SCHEME=https` into the env generator, pin `coa_shared_infra_ref` = `d59951a0f6cb…` (PR #18 head), ufw allow rules for 5901–5903/7642–7647/9723 deleted, post-reload https probes of the ladder. 3. **matou-app PR #448** (issue #447) — mobile loopback proxy keeps the upstream path prefix; `registrationResolve` stops using `.origin`; `getKeriaUrls()` strips trailing slashes. Desktop needs nothing from this PR. Deploy (needs your seat — the session's harness blocks PR merges and host changes): ``` # merge PR #18 on Forgejo, then mirror: git push origin forgejo/main:main (in matou-infrastructure) # merge PR #16 on Forgejo, then from the mds checkout: ansible-playbook playbooks/host.yml -l matou -t coa_shared --check --diff ansible-playbook playbooks/host.yml -l matou -t coa_shared git push gitlab origin/main:main ``` Expected on the host: keri containers recreated with `127.0.0.1:` bindings, four https probes green, `GET https://coa-infra.matou.nz/ngati-example/api/client-config` showing `https://coa-infra.matou.nz/keria/admin` etc. Then I re-run the ngati-example 0.6.8 AppImage setup drive (no rebuild needed: the app reads the URLs at runtime).
Author
Owner

Fixed and proven 2026-09-07. Ben merged matou-infrastructure PR #18 (8b70975, mirrored to GitLab) and mds PR #16 (c93c9f0) and ran the coa_shared role on matou: 18 ok / 7 changed / 0 failed — pin moved, keri containers recreated on loopback bindings, ten raw-port ufw rules deleted, Caddy ladder rendered, all four https probes green. Live now:

  • GET https://coa-infra.matou.nz/ngati-example/api/client-config → keri.admin_url https://coa-infra.matou.nz/keria/admin, /keria/boot, /keria/cesr, schema_server_url /schema, witnesses.urls[0] /witness/wan (+ matching oobis).
  • /keria/cesr/spec.yaml, /schema/, /witness/wan/oobi, /api/health → 200; raw :5901, :5904, :9723, :7642 → connection refused from the internet.
  • Desktop org setup on the unchanged ngati-example-0.6.8-linux.AppImage (fresh data dir, driven over CDP): Launch App → Connecting to KERIA → admin identity → org identity → registry → credential → community space → recovery phrase (12 words) → verification → welcome overlay → dashboard as Founding Member Test Admin, 57 s. Nav shows the kit's feature order; maramataka widget renders. The tenant's first real org exists; the admin identity lives in the laptop's ~/.config/Ngati Example (recovery phrase kept by the session, not posted).

Observations (not regressions, tracked separately): (1) the tenant still reports configured: false — the app's backend logs MATOU_CONFIG_SERVER_TOKEN is not set - org config will not mirror to the config server; that is the ADR 0008 bootstrap-token chain (coa #130/#131, infra #12/#13, matou-app #371/#372), stream B. (2) Post-setup credential polling times out twice resolving the org's agent OOBI through the new https path: KERIA fetches it fine (hairpin 200) but logs Unverified loc scheme reply for its own agent's location record — filed on matou-app. (3) Backend sign-in could not resolve key state → continues unauthenticated (packaged backend has no KERIA URL; pre-existing).

matou-app PR #448 (mobile loopback proxy keeps the prefix) is CI-green and awaits merge; desktop needed nothing from it. Closing.

**Fixed and proven 2026-09-07.** Ben merged matou-infrastructure PR #18 (8b70975, mirrored to GitLab) and mds PR #16 (c93c9f0) and ran the `coa_shared` role on `matou`: 18 ok / 7 changed / 0 failed — pin moved, keri containers recreated on loopback bindings, ten raw-port ufw rules deleted, Caddy ladder rendered, all four https probes green. Live now: - `GET https://coa-infra.matou.nz/ngati-example/api/client-config` → `keri.admin_url` `https://coa-infra.matou.nz/keria/admin`, `/keria/boot`, `/keria/cesr`, `schema_server_url` `/schema`, `witnesses.urls[0]` `/witness/wan` (+ matching oobis). - `/keria/cesr/spec.yaml`, `/schema/`, `/witness/wan/oobi`, `/api/health` → 200; raw `:5901`, `:5904`, `:9723`, `:7642` → connection refused from the internet. - **Desktop org setup on the unchanged `ngati-example-0.6.8-linux.AppImage`** (fresh data dir, driven over CDP): Launch App → Connecting to KERIA → admin identity → org identity → registry → credential → community space → recovery phrase (12 words) → verification → welcome overlay → dashboard as Founding Member `Test Admin`, 57 s. Nav shows the kit's feature order; maramataka widget renders. The tenant's first real org exists; the admin identity lives in the laptop's `~/.config/Ngati Example` (recovery phrase kept by the session, not posted). Observations (not regressions, tracked separately): (1) the tenant still reports `configured: false` — the app's backend logs `MATOU_CONFIG_SERVER_TOKEN is not set - org config will not mirror to the config server`; that is the ADR 0008 bootstrap-token chain (coa #130/#131, infra #12/#13, matou-app #371/#372), stream B. (2) Post-setup credential polling times out twice resolving the org's *agent* OOBI through the new https path: KERIA fetches it fine (hairpin 200) but logs `Unverified loc scheme reply` for its own agent's location record — filed on matou-app. (3) Backend sign-in `could not resolve key state` → continues unauthenticated (packaged backend has no KERIA URL; pre-existing). matou-app PR #448 (mobile loopback proxy keeps the prefix) is CI-green and awaits merge; desktop needed nothing from it. Closing.
ben closed this issue 2026-09-07 04:33:01 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/coa#141
No description provided.