monitor.cert-check
A TLS certificate's expiry state as a check status: ok and warning are up, critical is degraded, expired is down.
1.0.0 · published 2026-10-03 by charlie · Anterra
Pinned by 8 tests, run in TypeScript, Python and Rust.
What it does
A TLS certificate's expiry state (from `monitor.cert-expiry`) as one check behind a status page component, so an HTTPS target's component reflects its certificate as well as its HTTP probe in `monitor.component-state`.
| certificate state | check status | why | | --- | --- | --- | | `ok` | `up` | nothing to do | | `warning` | `up` | renew soon: a ticket for the operator, invisible to visitors | | `critical` | `degraded` | renewal is urgent; the site works but is at risk | | `expired` | `down` | browsers and API clients refuse the certificate |
For example
cert_check(ok)→ up a certificate with plenty of time left is upcert_check(warning)→ up a warning is still up: visitors are not affected yetcert_check(critical)→ degraded critical is degraded: renewal is urgent but the site still works
The function
The same function in TypeScript, Python and Rust, pinned by the same tests. Pick your language; the choice follows you around the registry.
pub fn cert_check(state: &str) -> String
| state | CertExpiryState | how close the certificate is to expiring, from monitor.cert-expiry |
| returns | CheckStatus |
Your code names it in one line, in the file that uses it
fune!(monitor.cert-check@^1); // then call cert_check(…)
Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.
use super::funejson::Value; ← the fune runtime: the JSON value the test vectors use; fune build keeps it only where a signature takes one
/// A certificate as one check behind a status page component. A warning
/// is work for the operator, not something a visitor notices, so it stays
/// up; critical is degraded because renewal is now urgent; an expired
/// certificate breaks every client, so it is down.
///
/// # Panics
/// Panics on an unknown state.
pub fn cert_check(state: &str) -> String {
let status = match state {
"ok" | "warning" => "up",
"critical" => "degraded",
"expired" => "down",
other => panic!("unknown certificate state: {}", other),
};
status.to_string()
}
pub fn fune_vector(args: &[Value]) -> Value {
let state = args[0].as_str().to_string();
Value::str(&cert_check(&state))
}Install
fune build
With that line in your source, in a Rust project (language rust in fune.project), fune build resolves it and its 2 dependencies, pins them in fune.lock, downloads only the Rust package of each, and builds the code above into your project’s .fune/build, one readable file per capability with a header linking back here. A crate’s build.rs runs it before every compile. Or pin a range in fune.project and build in one step:
fune add monitor.cert-check
The manifest, vectors and README with only the Rust implementation. Install it without the registry with fune add ./monitor.cert-check-1.0.0-rust.fune, or fetch it from a terminal with fune pull monitor.cert-check@1.0.0:rust.
The whole function, every language, is one file too: monitor.cert-check-1.0.0.fune, 6,468 bytes, sha256 dbf9c93a2ae200b76eadfcdfa274794e15dcf5cea51fecec6eb708774fc6879e. It installs into a project of any language.
Customise it in your app
The seams this capability offers. Put a marker directly above a function of your own and fune build wires it into the built code; the package on the registry is not changed, the built file’s header lists it under CUSTOMISED, and fune hooks lists every hook in the project. How hooks work.
before — your function gets the arguments and returns them, changed or not, or throws to refuse the call.
// fune: before monitor.cert-check
after — your function gets the result and the arguments, and returns the final result.
// fune: after monitor.cert-check
replace — inside this capability’s code only, calls to a dependency go to your function, with the same signature. Other capabilities that use it are unaffected; write in * to replace it everywhere.
// fune: replace monitor.cert-expiry in monitor.cert-check
// fune: replace monitor.check-status in monitor.cert-check
step — your function runs at a numbered point inside the function’s body, receives the in-scope values it names as parameters, and may return replacements. List the points with fune show monitor.cert-check --steps.
// fune: step monitor.cert-check after <n|label>
Tests
A version published now needs at least 8 tests for every function, and one that expects the error for each function that throws; the registry refuses it otherwise. fune verify --all runs each case in TypeScript, Python and Rust, and a project runs them again with fune verify. This page lists the cases; it does not run them. The exact JSON is vectors.json.
| Case | Arguments | Expected | |
|---|---|---|---|
| a certificate with plenty of time left is up | ok | → | up |
| a warning is still up: visitors are not affected yet | warning | → | up |
| critical is degraded: renewal is urgent but the site still works | critical | → | degraded |
| an expired certificate is down: every client refuses it | expired | → | down |
| an unknown state is an error | revoked | → | error: unknown certificate state: revoked |
| states are case-sensitive | OK | → | error: unknown certificate state: OK |
| an empty state is an error | → | error: unknown certificate state: | |
| a check status is not a certificate state: up is refused | up | → | error: unknown certificate state: up |
More from the author
## Why this shape
- **Warning stays up.** A status page is for the people using the service. A certificate with three weeks left changes nothing for them, so it must not turn the page amber; alert the operator from `monitor.cert-expiry` instead. - **Critical is degraded, not down.** The certificate still validates, so every request still succeeds. Degraded makes the risk visible without reporting an outage that has not happened. - **Expired is down.** After `notAfter` every standards-following client (RFC 5280 path validation) refuses the connection, which for its users is an outage however healthy the server is.
Combined with the HTTP probe in `monitor.component-state`, an expired certificate on a responsive server is a partial outage, and both down is a major one.
## Errors
- `unknown certificate state: X`, for anything but `ok`, `warning`, `critical` and `expired` (case-sensitive).
## Sources
- RFC 5280 section 4.1.2.5 (validity; a certificate is valid through its notAfter) and section 6.1.3 (path validation checks the validity period): https://www.rfc-editor.org/rfc/rfc5280
Files
| Path | Bytes |
|---|---|
| README.md | 1,717 |
| impl/python.py | 667 |
| impl/rust.rs | 748 |
| impl/typescript.ts | 805 |
| vectors.json | 895 |