Documentation
¶
Overview ¶
Package letsencrypt provides automatic TLS certificate management via Let's Encrypt using the ACME protocol. It supports both DNS-01 and HTTP-01 challenges.
Index ¶
- Constants
- func SupportedDNSProviders() []string
- type DNSCredentials
- type LegoLogger
- func (l *LegoLogger) Fatal(args ...interface{})
- func (l *LegoLogger) Fatalf(format string, args ...interface{})
- func (l *LegoLogger) Fatalln(args ...interface{})
- func (l *LegoLogger) Print(args ...interface{})
- func (l *LegoLogger) Printf(format string, args ...interface{})
- func (l *LegoLogger) Println(args ...interface{})
- type Manager
- func (m *Manager) CertPath() string
- func (m *Manager) EnsureCertificate() error
- func (m *Manager) GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)
- func (m *Manager) GetTLSConfig() *tls.Config
- func (m *Manager) Initialize() error
- func (m *Manager) KeyPath() string
- func (m *Manager) ObtainCertificate() error
- func (m *Manager) RenewCertificate() error
- func (m *Manager) StartAutoRenewal(interval time.Duration)
- func (m *Manager) Stop()
- type User
Constants ¶
const ( // ACME directory URLs LetsEncryptProduction = "https://acme-v02.api.letsencrypt.org/directory" LetsEncryptStaging = "https://acme-staging-v02.api.letsencrypt.org/directory" // Default values DefaultRenewBeforeDays = 30 DefaultHTTPPort = 80 )
Variables ¶
This section is empty.
Functions ¶
func SupportedDNSProviders ¶
func SupportedDNSProviders() []string
SupportedDNSProviders returns a list of supported DNS provider names
Types ¶
type DNSCredentials ¶
type DNSCredentials struct {
// Cloudflare
CloudflareAPIToken string `json:"cloudflare_api_token,omitempty"`
CloudflareEmail string `json:"cloudflare_email,omitempty"`
CloudflareAPIKey string `json:"cloudflare_api_key,omitempty"`
// AWS Route53
AWSAccessKeyID string `json:"aws_access_key_id,omitempty"`
AWSSecretAccessKey string `json:"aws_secret_access_key,omitempty"`
AWSRegion string `json:"aws_region,omitempty"`
// DigitalOcean
DigitalOceanToken string `json:"digitalocean_token,omitempty"`
// GoDaddy
GoDaddyAPIKey string `json:"godaddy_api_key,omitempty"`
GoDaddyAPISecret string `json:"godaddy_api_secret,omitempty"`
// Namecheap
NamecheapAPIUser string `json:"namecheap_api_user,omitempty"`
NamecheapAPIKey string `json:"namecheap_api_key,omitempty"`
}
DNSCredentials holds credentials for various DNS providers
type LegoLogger ¶
type LegoLogger struct {
// contains filtered or unexported fields
}
LegoLogger adapts zerolog to lego's StdLogger interface
func NewLegoLogger ¶
func NewLegoLogger(logger zerolog.Logger) *LegoLogger
NewLegoLogger creates a new lego-compatible logger wrapping zerolog
func (*LegoLogger) Fatal ¶
func (l *LegoLogger) Fatal(args ...interface{})
Fatal logs a fatal message and exits
func (*LegoLogger) Fatalf ¶
func (l *LegoLogger) Fatalf(format string, args ...interface{})
Fatalf logs a formatted fatal message and exits
func (*LegoLogger) Fatalln ¶
func (l *LegoLogger) Fatalln(args ...interface{})
Fatalln logs a fatal message with newline and exits
func (*LegoLogger) Print ¶
func (l *LegoLogger) Print(args ...interface{})
Print logs an info message
func (*LegoLogger) Printf ¶
func (l *LegoLogger) Printf(format string, args ...interface{})
Printf logs a formatted info message
func (*LegoLogger) Println ¶
func (l *LegoLogger) Println(args ...interface{})
Println logs an info message with newline
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles Let's Encrypt certificate acquisition and renewal
func NewManager ¶
NewManager creates a new Let's Encrypt certificate manager
func (*Manager) EnsureCertificate ¶
EnsureCertificate ensures a valid certificate exists, obtaining one if necessary
func (*Manager) GetCertificate ¶
func (m *Manager) GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)
GetCertificate returns the current TLS certificate for use with tls.Config.GetCertificate
func (*Manager) GetTLSConfig ¶
GetTLSConfig returns a tls.Config configured to use Let's Encrypt certificates
func (*Manager) Initialize ¶
Initialize sets up the ACME client and registers the account
func (*Manager) ObtainCertificate ¶
ObtainCertificate obtains a new certificate for the configured domains
func (*Manager) RenewCertificate ¶
RenewCertificate renews the current certificate if needed
func (*Manager) StartAutoRenewal ¶
StartAutoRenewal starts a background goroutine that checks for certificate renewal
type User ¶
type User struct {
Email string
Registration *registration.Resource
// contains filtered or unexported fields
}
User implements acme.User for lego
func (*User) GetPrivateKey ¶
func (u *User) GetPrivateKey() crypto.PrivateKey
func (*User) GetRegistration ¶
func (u *User) GetRegistration() *registration.Resource