tlsutil

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 5 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 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

View Source
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

func CertPool(caFile string) (*x509.CertPool, error)

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

func ClientConfig(caFile, certFile, keyFile string) (*tls.Config, error)

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

func ServerConfig(certFile, keyFile, clientCAFile string) (*tls.Config, error)

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.

Jump to

Keyboard shortcuts

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