nx_hgw_mtls_resolve.nx
buildroot/runtime/nx_hgw_mtls_resolve.nx
about
nx_hgw_mtls_resolve.nx -- R7 ENFORCEMENT wiring: the mTLS-first handle resolution the doc wall plugs in.
nx_hub_gw_decide.nx:91-94 is the bug, in three lines: it reads the `X-Nishi-Session:` header, resolves the
token -> handle, and routes on that handle. A top-level browser NAVIGATION carries no custom header -> the
handle is empty -> mr_route DENY -> 302 /login = "logs in but isn't let in". The mTLS fix lives exactly here:
the verified client cert rides EVERY connection (nav/refresh/new-tab) at the TLS layer, so resolve the handle
from the CERT first, and fall back to the header token only when no cert was presented (never-lockout).
This is that resolution, pure + gated (composes nx_mtls_serve_decide). The live hgw_decide swaps its three
lines for ONE call to nx_hgw_mtls_resolve_handle, passing the run loop's out_auth + client cert; everything
downstream (mr_route + the status map) is byte-identical. The uid->handle index models the proven live
olgd_idx_lookup; the sessions registry is the existing token->handle fallback.
license_tier: ORIGINAL expect_exit: 0
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_mtls_serve_decision.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 16 | const NX_MAGIC_4096: i64 = 4096 |
| 18 | const NX_HMH_REJECT: i64 = 0 - 1 // a cert was presented but FAILED verify -> caller returns 403, never falls back |
functions
| 21 | func hmh_lookup(reg: *u8, reglen: i64, key: *u8, keylen: i64, out: *u8, cap: i64) -> i64 called by 1: nx_hgw_mtls_resolve_handle |
| 54 | func nx_hgw_mtls_resolve_handle( |
| 79 | func hr_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 80 | func hr_row(name: *u8, ok: i64) -> i64 { if ok == 1 { hr_w(" PASS " as *u8) } else { hr_w(" FAIL " as *u8) } hr_w(name); hr_w("\n" as *u8); return ok } |
| 81 | func hr_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: hr_streq |
| 82 | func hr_streq(a: *u8, an: i64, b: *u8) -> i64 { let bn: i64 = hr_slen(b); if an != bn { return 0 } var i: i64 = 0; while i < an { if a[i] != b[i] { return 0 } i = i + 1 } return 1 } |
| 83 | func hr_put(buf: *u8, off: i64, key: *u8, keylen: i64, val: *u8, vallen: i64) -> i64 called by 1: main |
| 92 | func main() -> i64 |