certs

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 22 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 certs keeps a TLS certificate for every public hostname (§5.0.2). The controller is the ACME client (HTTP-01 through Traefik) and hands the certificates to Traefik in its dynamic config. Until a real certificate is issued, or when ACME fails, a self-signed placeholder keeps HTTPS working.

Index

Constants

View Source
const (
	StatusValid       = "valid"        // issued by ACME
	StatusPending     = "pending"      // self-signed placeholder, ACME attempt due
	StatusFailed      = "failed"       // ACME failed, retrying with backoff
	StatusRateLimited = "rate_limited" // the CA rate-limited us (§5.0.2)
	StatusSelfSigned  = "self_signed"  // ACME disabled

	IssuerACME       = "acme"
	IssuerSelfSigned = "self-signed"

	// TopicUpdated carries a View whenever a certificate changes.
	TopicUpdated = "certificate.updated"
	// ChallengePrefix is routed from Traefik's HTTP entrypoint to the controller.
	ChallengePrefix = "/.well-known/acme-challenge/"
)

Status values.

Variables

View Source
var ErrUnknownHost = errors.New("no certificate is managed for this host")

ErrUnknownHost is returned by Renew for hosts that need no certificate.

Functions

This section is empty.

Types

type Config

type Config struct {
	// ACME enables issuing from DirectoryURL; otherwise certificates stay self-signed.
	ACME         bool
	DirectoryURL string
	Email        string
	// HTTPClient talks to the ACME server (tests trust Pebble's CA here).
	HTTPClient  *http.Client
	RenewBefore time.Duration // default 30 days
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func New

func New(st *store.Store, box *secrets.Box, bus *events.Bus, log *slog.Logger, cfg Config) *Manager

func (*Manager) Kick

func (m *Manager) Kick()

Kick asks the loop to reconcile now.

func (*Manager) List

func (m *Manager) List() []View

List returns the certificates for the current hosts.

func (*Manager) Load

func (m *Manager) Load(ctx context.Context) error

Load reads stored certificates. Call before serving Traefik config.

func (*Manager) PairFor added in v0.1.2

func (m *Manager) PairFor(host string) (Pair, bool)

PairFor returns host's certificate and key, if it has one.

func (*Manager) Pairs

func (m *Manager) Pairs() []Pair

Pairs returns the certificates Traefik should serve.

func (*Manager) Pin

func (m *Manager) Pin(host string) string

Pin returns the public-key pin ("sha256//<base64>", as curl's --pinnedpubkey takes it) of host's certificate while it is self-signed, and "" once a CA issued it. Join commands carry the pin so new nodes can verify the controller on a private network where ACME cannot issue.

func (*Manager) Reconcile

func (m *Manager) Reconcile(ctx context.Context)

Reconcile makes sure every host has a certificate and renews due ones.

func (*Manager) Renew

func (m *Manager) Renew(ctx context.Context, host string) error

Renew clears any backoff for host and retries ACME now.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run reconciles on every Kick and every few minutes until ctx ends.

func (*Manager) SelfSignedBundle

func (m *Manager) SelfSignedBundle(hosts ...string) string

SelfSignedBundle concatenates the self-signed certificates of hosts (skipping CA-issued ones): what a client of the registry must trust, as Docker also fetches tokens from the dashboard host.

func (*Manager) SelfSignedPEM

func (m *Manager) SelfSignedPEM(host string) string

SelfSignedPEM returns host's certificate while it is self-signed, for clients that must be told to trust it (Docker on nodes, §5.9), else "".

func (*Manager) ServeHTTP

func (m *Manager) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP answers HTTP-01 challenges at /.well-known/acme-challenge/{token}.

func (*Manager) SetHosts

func (m *Manager) SetHosts(hosts []string)

SetHosts declares the hostnames that need certificates.

type Pair

type Pair struct{ CertPEM, KeyPEM string }

Pair is a PEM certificate chain and key, as Traefik takes them.

type View

type View struct {
	Host          string     `json:"host"`
	Issuer        string     `json:"issuer"`
	Status        string     `json:"status"`
	NotAfter      time.Time  `json:"notAfter"`
	LastError     string     `json:"lastError"`
	Failures      int        `json:"failures"`
	NextAttemptAt *time.Time `json:"nextAttemptAt"`
	UpdatedAt     time.Time  `json:"updatedAt"`
}

View is a certificate as shown in the API (never the key).

Jump to

Keyboard shortcuts

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