Documentation
¶
Overview ¶
Package certloader builds a reloadable crypto/tls.Config backed by files on disk, so cert rotation does not require a server restart. The package is transport-agnostic — the produced crypto/tls.Config is consumed by the Tetragon gRPC server.
The design — directory-watched material, atomic snapshot swapped on reload, crypto/tls.Config.GetConfigForClient pinning a snapshot for the duration of each handshake — is adapted from cilium/cilium/pkg/crypto/certloader (Apache-2.0).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// CertFile is a PEM-encoded server cert (leaf + optional intermediates).
CertFile string
// KeyFile is the PEM-encoded private key for CertFile.
KeyFile string
// ClientCAFiles is a list of PEM CA bundles used to verify client
// certs. Required when RequireClientCert is true.
ClientCAFiles []string
// RequireClientCert toggles mTLS (RequireAndVerifyClientCert).
RequireClientCert bool
}
Config drives a server-side TLS configuration. Zero values disable TLS.
type Reloader ¶
type Reloader struct {
// contains filtered or unexported fields
}
Reloader holds TLS material and atomically swaps it on Reload, so a rotation does not interrupt in-flight handshakes. Safe for concurrent use.
func NewReloaderLazy ¶
NewReloaderLazy constructs a Reloader without requiring the TLS material to exist on disk. Handshakes performed before the first successful Reload fail with "certloader: no certificate loaded"; pair with Watch so the first reload happens automatically once the files appear.
Use this when the agent may start before its provisioner (cert-manager, cilium-certgen Job) has written the Secret.
func (*Reloader) Ready ¶
Ready reports whether a Reload has succeeded at least once. A Reloader returned by [NewReloader] is always Ready; one returned by NewReloaderLazy becomes Ready after Watch observes the TLS files on disk.
func (*Reloader) Reload ¶
Reload re-reads the cert/key and CA bundles from disk and atomically replaces the active snapshot when they changed. Concurrent calls are serialized by reloadMu.
func (*Reloader) ServerConfig ¶
ServerConfig returns a tls.Config suitable for [credentials.NewTLS]. The returned value is stable across reloads.