Documentation
¶
Overview ¶
Package tlsutil holds the TLS loading primitives shared by every component that terminates or dials TLS: the API listener, the embedded broker, the worker's broker client and the worker's enrollment client.
Those callers live on both sides of an import boundary: internal/config pulls internal/auth/oidc, so the worker binary cannot import it, and internal/bus must not import internal/config. This package imports nothing internal, so all of them can reach it.
It holds only loading. Validation of operator-supplied paths stays in internal/config, the one place that knows config keys and can name them in an error.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrIncompleteClientPair = errors.New("a client certificate needs both a certificate file and a key file")
ErrIncompleteClientPair is ClientConfig's error for a client certificate without its key, or a key without its certificate, so a caller can name its own config keys.
Functions ¶
func CertPool ¶
CertPool reads a PEM bundle into a certificate pool.
Callers use this for the "empty means system roots, set means that CA only" rule: an empty path never reaches here, and a non-empty one produces a pool that pins the acceptable issuer rather than widening it.
func ClientConfig ¶
ClientConfig builds a client *tls.Config: TLS 1.2 or later, trusting caFile's certificates when it is set (else the system pool), and presenting the certFile/keyFile pair when both are set. Setting only one of the pair is an error. The caller sets ServerName or InsecureSkipVerify if it needs them.
func LeafOf ¶
func LeafOf(pair tls.Certificate) (*x509.Certificate, error)
LeafOf returns the parsed leaf certificate of a loaded keypair.
tls.LoadX509KeyPair normally populates Leaf itself, but only when the x509keypairleaf GODEBUG is left at its default; under GODEBUG=x509keypairleaf=0 it stays nil, so the re-parse below is a real fallback rather than dead code.
func ServerConfig ¶
ServerConfig builds a server *tls.Config from a certificate/key pair, optionally requiring client certificates signed by clientCAFile.
It is called once at startup, with paths the caller has already validated, so the certificate is read exactly once: handing the paths to ListenAndServeTLS instead would read them a second time, and a rotation landing between the two reads would serve a half-written file.
Types ¶
This section is empty.