clusterca

package
v1.0.501 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package clusterca owns the cluster CA's validity policy (CHAOS-50, register row CA-13; ADR-0048): when the control plane's cluster CA may sign a node certificate, how an unusable CA is classified for health and metrics surfaces, which operator action fixes each class, and the clamp that keeps a node certificate inside its issuer's validity window.

The cluster CA is the trust root of the whole control plane. Every enrolled data-plane node's mTLS client certificate chains to it, and Go's path validation checks the validity window of every certificate in the chain, roots included. A CA outside its own window can still sign (neither x509.CreateCertificate nor the ECDSA primitive checks the parent's NotBefore/NotAfter), so without this gate a re-enrollment against a dead CA "succeeds" and produces a certificate that fails every handshake.

The policy deliberately differs from the inspection CA's (internal/ca): it applies no future clock-skew tolerance to NotBefore, because the verifier that would reject the issued certificate runs on the same node, against the same clock, as the signer. See Usable.

Package main owns the CA instance (key material, rotation, import, replication, persistence and every call site). This package is pure: it holds no mutable package-level state (only error sentinels), starts no goroutines and does no I/O or logging. Callers pass the current time.

Index

Constants

View Source
const RenewalWindow = 30 * 24 * time.Hour

RenewalWindow is the horizon inside which a cluster CA is treated as expiring soon. It is deliberately the SAME 30 days as the control plane's CA rotation horizon and the data-plane node-certificate renewal window, so "the CA is inside its rotation window" and "node certificates clamped by this CA are inside their renewal window" are one condition rather than three that drift apart.

Variables

View Source
var (
	ErrExpired     = errors.New("expired")
	ErrNotYetValid = errors.New("not yet valid")
)

ErrExpired and ErrNotYetValid are wrapped ALONGSIDE ErrUnusable so callers can tell a genuine expiry (recovery: rotate or import a new trust root) from a CLOCK fault (recovery: fix NTP; rotating would churn the fleet's trust root for nothing).

View Source
var ErrUnusable = errors.New("cluster CA unusable")

ErrUnusable is the sentinel returned (wrapped) when the cluster CA cannot produce a node certificate that any peer in the cluster will accept. Callers match it with errors.Is; the wrapped text carries the operator-actionable detail (which bound was violated, and when) and contains no key material.

Functions

func ClampNodeValidity

func ClampNodeValidity(notBefore, notAfter time.Time, ca *x509.Certificate) (leafNotBefore, leafNotAfter time.Time, clampedToIssuer bool)

ClampNodeValidity narrows a proposed node-certificate window so the certificate can never outlive — or predate — the cluster CA that issues it. clampedToIssuer reports whether either bound moved. A nil ca leaves the window unchanged.

Unclamped, a node enrolled at any point in the CA's final year would hold a certificate whose stated expiry is months past its issuer's: node listings and the node's own expiry check report it valid while every handshake fails, because RFC 5280 path validation evaluates the whole chain at the time of use. Clamping does not shorten any window that would otherwise have worked; it makes the certificate honest about when trust actually ends. A clamped certificate inside the data plane's 30-day renewal window puts the node into renewal, which turns a silent cliff into visible pressure. Because the clamp horizon and the CA's rotation window are both RenewalWindow, a healthy control plane rotates before any clamp is reachable, so on a healthy fleet this function is inert.

func Remediation

func Remediation(kind string) string

Remediation returns the operator action that actually fixes the given UnusableKind. It is kept next to the classifier so the two can never drift; a clock fault must NOT be answered with a fleet-wide trust-root rotation.

func UnusableKind

func UnusableKind(err error) string

UnusableKind classifies a Usable error into a stable, machine-readable kind for metrics and health surfaces: "expired", "not_yet_valid", or "unavailable" (no CA loaded, or anything else). It returns "" for nil.

func Usable

func Usable(cert *x509.Certificate, now time.Time) error

Usable is the cluster CA validity predicate: nil means a certificate signed by cert at instant now will be accepted by the cluster's mTLS peers. A nil cert means no cluster CA is loaded. The caller supplies the clock so tests can drive it explicitly instead of waiting ten years for a CA to expire.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL