code wiki / (root) / nx_aw_mtls_inject.nx

nx_aw_mtls_inject.nx

buildroot/runtime/nx_aw_mtls_inject.nx

4807 B99 linesdepth 12pulls 18 transitivereach 2 importersview sourcekind librarytopic aw
docsdependenciesstructsconstsfunctions

about

nx_aw_mtls_inject.nx -- inject the VERIFIED mTLS client identity into the decrypted HTTP request as an X-Nishi-Cert-Identity header, so the loopback backend can serve-by-identity. This is the genuinely NEW logic of the sovereign mTLS carrier (the TLS handshake + the reverse-proxy mechanics are already proven: run_ecdsa_mtls loopback+interop 6/6, nx_aw_tlsproxy live for the CMS admin). THE PROXY IS THE TRUST BOUNDARY (rule 12, defensive at boundaries). Two invariants, both security-floor: 1. ALWAYS strip any client-supplied X-Nishi-Cert-Identity header from the request -- else a NO-cert client simply sends its own and the backend trusts a SPOOFED identity. Strip happens for every auth value (0/1/-1) and only inside the HEADER section (a body that happens to contain the string is left verbatim). 2. Inject the REAL identity ONLY when auth==1 (a client cert was PRESENTED and its CertificateVerify VERIFIED this handshake). auth==0 (no cert) or auth==-1 (bad cert) => no identity injected = request- not-require / NEVER-LOCKOUT (the backend falls back to its X-Nishi-Session header path exactly as today). Identity = the cert Subject CN (hex(user_id_hash)) via the canonical nx_mtls_cert_identity -- the SAME stable id the OPAQUE/HR stack keys on, so the backend maps it with the existing uidhex->handle index. license_tier: ORIGINAL expect_exit: 0

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_mtls_authz.nx nx_aw_mtls_inject.nx nx_aw_mtls_inject_gate.nx nx_aw_mtls_proxy.nx

imports: nx_syscalls.nxnx_mtls_authz.nx

imported by: nx_aw_mtls_inject_gate.nxnx_aw_mtls_proxy.nx

structs

none

consts

21const MI_HDR: *u8 = "X-Nishi-Cert-Identity: " // 23 bytes (name + ": ")

functions

24func mi_lc(b: i64) -> i64 { if b >= 65 { if b <= 90 { return b + 32 } } return b }
called by 1: mi_ci_starts
27func mi_ci_starts(req: *u8, i: i64, n: i64, lit: *u8) -> i64
called by 2: mtls_inject_identityg_has_ci calls 1: mi_lc
38func mi_line_end(req: *u8, start: i64, n: i64) -> i64
48func mi_copy(dst: *u8, o: i64, src: *u8, a: i64, b: i64) -> i64
57func mtls_inject_identity(req: *u8, req_n: i64, cert: *u8, cc_len: i64, auth: i64, out: *u8, out_cap: i64) -> i64