nx_cert_monitor.nx
buildroot/runtime/nx_cert_monitor.nx
about
nx_cert_monitor.nx -- CERT-EXPIRY MONITOR (closes hosting_research gap #3 "cert-expiry-monitor", 3/0
CONFIRMED: best-in-class hosts auto-renew + monitor SSL expiry; Nishi certs are hardcoded, no expiry
alert -- "a silent cert expiry = a self-inflicted outage"). Pure COMPOSITION (rule 15 DRY): reuses the
shipped X.509 stack -- x509_parse (nx_x509) captures the validity field; x509_validity_get
(nx_x509_validity) returns notBefore/notAfter as Unix epoch seconds via parse_utctime/parse_gentime;
sys_now_realtime_sec is `now`. We just compute days-until-expiry and turn it into an actionable verdict.
module: nishi-core.supervision.cert_monitor capability: DAEMON_ROBUSTNESS / observability
dependencies 2 imports · 4 importers
imports: nx_x509.nxnx_x509_validity.nx
imported by: nx_cert_autorenew_lib.nxnx_cert_debug.nxnx_cert_monitor_gate.nxnx_status_page.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 11 | const CM_MAGIC_86400: i64 = 86400 |
| 12 | const CM_MAGIC_65536: i64 = 65536 |
| 13 | const CM_MAGIC_1024: i64 = 1024 |
| 15 | const CM_OK: i64 = 0 // > warn_days remain |
| 16 | const CM_WARN: i64 = 1 // 0..warn_days remain -> RENEW NOW (the alert best-in-class fires, Nishi never did) |
| 17 | const CM_EXPIRED: i64 = 2 // notAfter is in the past -> the site is serving an expired cert (or about to fail TLS) |
| 18 | const CM_NOCERT: i64 = 3 // could not read/parse the cert |
| 19 | const CM_WARN_DAYS: i64 = 21 // LE certs live 90d; alert ~3 weeks before expiry (well inside the renew window) |
functions
| 21 | func cm_days_until(na_epoch: i64, now_epoch: i64) -> i64 { return (na_epoch - now_epoch) / CM_MAGIC_86400 } |
| 22 | func cm_verdict(na_epoch: i64, now_epoch: i64, warn_days: i64) -> i64 |
| 28 | func cm_name(v: i64) -> *u8 |
| 35 | func cm_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 36 | func cm_n(v: i64) -> i64 { let t: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m; sys_write(1,"-" as *u8,1)} var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} let b: *u8=sys_mmap(28); var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 } |
| 40 | func cm_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 50 | func cm_status(path: *u8, out_days: *i64, out_na: *i64) -> i64 |
| 64 | func cm_check_file(path: *u8) -> i64 |
| 73 | func main() -> i64 |