certmanager

package
v0.8.32 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 10 Imported by: 1 module, 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 certmanager provides automatic TLS certificate provisioning via Let's Encrypt (ACME). It wraps golang.org/x/crypto/acme/autocert and exposes helpers for the web server and DoT server to share certificates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertInfo

type CertInfo struct {
	Domain    string    `json:"domain"`
	Issuer    string    `json:"issuer"`
	Subject   string    `json:"subject"`
	NotBefore time.Time `json:"not_before"`
	NotAfter  time.Time `json:"not_after"`
	DNSNames  []string  `json:"dns_names"`
	AutoTLS   bool      `json:"auto_tls"`
	ACME      bool      `json:"acme"`
}

CertInfo describes the currently active certificate.

func InfoFromStatic

func InfoFromStatic(certFile, keyFile string) (*CertInfo, error)

InfoFromStatic returns CertInfo by reading a static cert+key file pair.

type Manager

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

Manager wraps autocert.Manager and provides certificate status inspection.

func New

func New(domain, email, cacheDir string, staging bool, logger *slog.Logger) *Manager

New creates a new certificate manager. cacheDir is the directory where certs are stored on disk. If staging is true, the Let's Encrypt staging endpoint is used (for testing).

func (*Manager) Domain

func (m *Manager) Domain() string

Domain returns the managed domain name.

func (*Manager) ForceRenew

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

ForceRenew removes the cached certificate so autocert provisions a new one on the next TLS handshake.

func (*Manager) HTTPHandler

func (m *Manager) HTTPHandler(fallback http.Handler) http.Handler

HTTPHandler returns an http.Handler that serves ACME HTTP-01 challenges and redirects all other traffic to HTTPS. Use this on port 80.

func (*Manager) Info

func (m *Manager) Info() *CertInfo

Info returns information about the currently active certificate.

func (*Manager) TLSConfig

func (m *Manager) TLSConfig() *tls.Config

TLSConfig returns a *tls.Config that automatically provisions certificates. Use this for both the web server and DoT server.

Jump to

Keyboard shortcuts

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