#4708·crowdsec

LAPI: reload the server TLS certificate when its files change

Author: ohartwigCreated Sep 26, 2026Updated Sep 26, 2026
Labelskind/enhancementneeds/triage

The LAPI loads its server certificate once: listenAndServeLAPI calls http.Server.ServeTLS(listener, certFile, keyFile) (pkg/apiserver/apiserver.go, v1.8.1). With short-lived certificates that are renewed in place, the LAPI keeps serving the first certificate until it expires, and every client then fails the handshake at the same moment. Examples are Kubernetes pod certificates (renewed at about two thirds of their lifetime, 24 h by default) and cert-manager with a mounted Secret.

What works today: SIGHUP. The reload handler rebuilds the API server, and the listener comes back after about two seconds with the new certificate (measured on v1.8.1). That needs something outside the process to watch the files and send the signal. We run such a watcher in the container entrypoint for now.

Proposal: serve through tls.Config.GetCertificate, backed by a small loader that re-reads certificate and key when their content changes (checked at most every few seconds), the way many Go servers do. There is no behaviour change for static certificates, and no restart or SIGHUP is needed on renewal.

Related: #2810 and #4269 cover the agent's client certificate; this is the server side.