tlsreload

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package tlsreload serves certificates that cert-manager renews in place: the key pair and the CA bundle are re-read from the mounted files when they change, so a renewal never needs a pod restart.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Files

type Files struct {
	CertFile, KeyFile string
	// CAFile is the client CA (server side) or the server CA; empty if unused.
	CAFile string
	// MinInterval limits how often the files are stat'ed. Zero checks every time.
	MinInterval time.Duration
	// OptionalClientAuth makes a client certificate optional on the server side: when one is
	// presented it must still verify against the CA. The caller then decides, per call, whether
	// a certificate is required (the agent's Enroll has none yet).
	OptionalClientAuth bool
	// contains filtered or unexported fields
}

Files is a key pair and an optional CA bundle on disk. A change is detected by the modification time and size of the files (Secret volumes swap a symlink, and os.Stat follows it), checked on demand and at most once per MinInterval. A failed reload (for instance a half-written pair) keeps serving the last good material and is retried on the next check.

func New

func New(certFile, keyFile, caFile string) (*Files, error)

New loads the files once and fails if they are unusable.

func (*Files) GetCertificate

func (f *Files) GetCertificate(*tls.ClientHelloInfo) (*tls.Certificate, error)

GetCertificate serves the current server certificate.

func (*Files) GetClientCertificate

func (f *Files) GetClientCertificate(*tls.CertificateRequestInfo) (*tls.Certificate, error)

GetClientCertificate presents the current client certificate.

func (*Files) ServerConfig

func (f *Files) ServerConfig(nextProtos ...string) *tls.Config

ServerConfig returns a tls.Config whose per-connection config always carries the current certificate and, when a CA file is set, requires a client certificate signed by the current CA. The per-connection config comes from GetConfigForClient, so NextProtos must be complete here (gRPC needs "h2").

Jump to

Keyboard shortcuts

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