certs

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package certs provides TLS certificates from Let's Encrypt for every host lfr serves (mail host, list websites, MTA-STS hosts), renewing them automatically, with a self-signed fallback so STARTTLS keeps working before DNS is in place.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	Dir      string
	Email    func(ctx context.Context) string
	DirURL   func(ctx context.Context) string
	Allowed  func(ctx context.Context, host string) bool
	Hostname func(ctx context.Context) string
	// contains filtered or unexported fields
}

Manager hands out certificates.

func (*Manager) Challenge

func (m *Manager) Challenge(next http.Handler) http.Handler

Challenge answers ACME HTTP-01 challenges and passes everything else to next. It works on port 80 and, behind a proxy that upgrades to HTTPS, on 443 too.

func (*Manager) Forget

func (m *Manager) Forget()

Forget clears remembered failures, e.g. after DNS was fixed.

func (*Manager) GetCertificate

func (m *Manager) GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)

GetCertificate serves HTTPS and SMTP STARTTLS. Clients without SNI (most mail servers) get the mail host's certificate. When no real certificate can be had for an allowed host, a self-signed one keeps TLS available.

func (*Manager) Inspect

func (m *Manager) Inspect(host string) State

Inspect reports the cached certificate of host without requesting one.

func (*Manager) SMTPCertificate

func (m *Manager) SMTPCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)

SMTPCertificate is GetCertificate for STARTTLS: mail servers send all kinds of names (or none), and a failed handshake makes some deliver in clear text, so any name it does not serve gets the mail host's certificate.

func (*Manager) TLSConfig

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

TLSConfig is the server configuration for HTTPS.

type State

type State struct {
	Host    string    `json:"host"`
	Valid   bool      `json:"valid"`
	Expires time.Time `json:"expires,omitzero"`
	Issuer  string    `json:"issuer,omitempty"`
}

State is the certificate status of one host.

Jump to

Keyboard shortcuts

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