Documentation
¶
Overview ¶
Package letsencrypt provides a module for automatic SSL certificate generation via Let's Encrypt for the modular framework.
Package letsencrypt provides a module for automatic SSL certificate generation via Let's Encrypt for the modular framework.
Package letsencrypt provides a module for automatic SSL certificate generation via Let's Encrypt for the modular framework.
Index ¶
- Constants
- type CertificateService
- type ChallengeHandler
- type CloudflareConfig
- type DNSProviderConfig
- type DigitalOceanConfig
- type HTTPProviderConfig
- type LetsEncryptConfig
- type LetsEncryptModule
- func (m *LetsEncryptModule) Config() interface{}
- func (m *LetsEncryptModule) Domains() []string
- func (m *LetsEncryptModule) GetCertificate(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error)
- func (m *LetsEncryptModule) GetCertificateForDomain(domain string) (*tls.Certificate, error)
- func (m *LetsEncryptModule) Name() string
- func (m *LetsEncryptModule) RevokeCertificate(domain string) error
- func (m *LetsEncryptModule) Start(ctx context.Context) error
- func (m *LetsEncryptModule) Stop(ctx context.Context) error
- type Route53Config
- type User
Constants ¶
const ( // CAStaging is the URL for Let's Encrypt's staging environment CAStaging = "https://acme-staging-v02.api.letsencrypt.org/directory" // CAProduction is the URL for Let's Encrypt's production environment CAProduction = "https://acme-v02.api.letsencrypt.org/directory" )
Constants for Let's Encrypt URLs
const ModuleName = "letsencrypt"
ModuleName is the name of this module
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CertificateService ¶
type CertificateService interface {
// GetCertificate returns a certificate for the given ClientHello
GetCertificate(*tls.ClientHelloInfo) (*tls.Certificate, error)
// GetCertificateForDomain returns a certificate for the specified domain
GetCertificateForDomain(domain string) (*tls.Certificate, error)
// Domains returns a list of domains this service can provide certificates for
Domains() []string
}
CertificateService defines the interface for a service that can provide TLS certificates
type ChallengeHandler ¶
type ChallengeHandler interface {
// PresentChallenge is called when a challenge token needs to be made available
PresentChallenge(domain, token, keyAuth string) error
// CleanupChallenge is called when a challenge token needs to be removed
CleanupChallenge(domain, token, keyAuth string) error
}
ChallengeHandler defines the interface for handlers that can handle ACME challenges
type CloudflareConfig ¶
type CloudflareConfig struct {
Email string `yaml:"email" json:"email"`
APIKey string `yaml:"api_key" json:"api_key"`
APIToken string `yaml:"api_token" json:"api_token"`
}
CloudflareConfig holds the configuration for Cloudflare DNS API
type DNSProviderConfig ¶
type DNSProviderConfig struct {
// Provider is the name of the DNS provider (e.g., "cloudflare", "route53", etc.)
Provider string `yaml:"provider" json:"provider"`
// Parameters is a map of provider-specific configuration parameters
Parameters map[string]string `yaml:"parameters" json:"parameters"`
// Provider-specific configurations
Cloudflare *CloudflareConfig `yaml:"cloudflare,omitempty" json:"cloudflare,omitempty"`
Route53 *Route53Config `yaml:"route53,omitempty" json:"route53,omitempty"`
DigitalOcean *DigitalOceanConfig `yaml:"digitalocean,omitempty" json:"digitalocean,omitempty"`
}
DNSProviderConfig defines the configuration for DNS challenge providers
type DigitalOceanConfig ¶
type DigitalOceanConfig struct {
AuthToken string `yaml:"auth_token" json:"auth_token"`
}
DigitalOceanConfig holds the configuration for DigitalOcean DNS API
type HTTPProviderConfig ¶
type HTTPProviderConfig struct {
// Use the built-in HTTP server for challenges
UseBuiltIn bool `yaml:"use_built_in" json:"use_built_in"`
// Port to use for the HTTP challenge server (default: 80)
Port int `yaml:"port" json:"port"`
}
HTTPProviderConfig defines the configuration for HTTP challenge providers
type LetsEncryptConfig ¶
type LetsEncryptConfig struct {
// Email is the email address to use for registration with Let's Encrypt
Email string `yaml:"email" json:"email"`
// Domains is a list of domain names to obtain certificates for
Domains []string `yaml:"domains" json:"domains"`
// UseStaging determines whether to use Let's Encrypt's staging environment
// Set to true for testing to avoid rate limits
UseStaging bool `yaml:"use_staging" json:"use_staging"`
// UseProduction is the opposite of UseStaging, for clarity in configuration
UseProduction bool `yaml:"use_production" json:"use_production"`
// StoragePath is the directory where certificates and account information will be stored
StoragePath string `yaml:"storage_path" json:"storage_path"`
// RenewBefore sets how long before expiry certificates should be renewed (in days)
RenewBefore int `yaml:"renew_before" json:"renew_before"`
// RenewBeforeDays is an alias for RenewBefore for backward compatibility
RenewBeforeDays int `yaml:"renew_before_days" json:"renew_before_days"`
// AutoRenew enables automatic certificate renewal
AutoRenew bool `yaml:"auto_renew" json:"auto_renew"`
// UseDNS indicates whether to use DNS challenges instead of HTTP
UseDNS bool `yaml:"use_dns" json:"use_dns"`
// DNSProvider configuration for DNS challenges
DNSProvider *DNSProviderConfig `yaml:"dns_provider,omitempty" json:"dns_provider,omitempty"`
// DNSConfig is a map of DNS provider specific configuration parameters
DNSConfig map[string]string `yaml:"dns_config,omitempty" json:"dns_config,omitempty"`
// HTTPProvider configuration for HTTP challenges
HTTPProvider *HTTPProviderConfig `yaml:"http_provider,omitempty" json:"http_provider,omitempty"`
// HTTPChallengeHandler is an HTTP handler for HTTP-01 challenges
HTTPChallengeHandler http.Handler `yaml:"-" json:"-"`
// CustomCACertificate is a custom CA certificate to be trusted
CustomCACertificate []byte `yaml:"-" json:"-"`
}
LetsEncryptConfig defines the configuration for the Let's Encrypt module.
func (*LetsEncryptConfig) Validate ¶
func (c *LetsEncryptConfig) Validate() error
Validate checks if the configuration is valid and sets default values where appropriate.
type LetsEncryptModule ¶
type LetsEncryptModule struct {
// contains filtered or unexported fields
}
LetsEncryptModule represents the Let's Encrypt module
func New ¶
func New(config *LetsEncryptConfig) (*LetsEncryptModule, error)
New creates a new Let's Encrypt module
func (*LetsEncryptModule) Config ¶
func (m *LetsEncryptModule) Config() interface{}
Config returns the module's configuration
func (*LetsEncryptModule) Domains ¶
func (m *LetsEncryptModule) Domains() []string
Domains returns the list of domains this service can provide certificates for
func (*LetsEncryptModule) GetCertificate ¶
func (m *LetsEncryptModule) GetCertificate(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error)
GetCertificate implements the CertificateService.GetCertificate method to be used with tls.Config.GetCertificate
func (*LetsEncryptModule) GetCertificateForDomain ¶
func (m *LetsEncryptModule) GetCertificateForDomain(domain string) (*tls.Certificate, error)
GetCertificateForDomain returns a certificate for the specified domain
func (*LetsEncryptModule) Name ¶
func (m *LetsEncryptModule) Name() string
Name returns the name of the module
func (*LetsEncryptModule) RevokeCertificate ¶
func (m *LetsEncryptModule) RevokeCertificate(domain string) error
RevokeCertificate revokes a certificate for the specified domain
type Route53Config ¶
type Route53Config struct {
AccessKeyID string `yaml:"access_key_id" json:"access_key_id"`
SecretAccessKey string `yaml:"secret_access_key" json:"secret_access_key"`
Region string `yaml:"region" json:"region"`
HostedZoneID string `yaml:"hosted_zone_id" json:"hosted_zone_id"`
}
Route53Config holds the configuration for AWS Route53 DNS API
type User ¶
type User struct {
Email string
Registration *registration.Resource
Key crypto.PrivateKey // Changed from certcrypto.PrivateKey to crypto.PrivateKey
}
User implements the ACME User interface for Let's Encrypt
func (*User) GetPrivateKey ¶
func (u *User) GetPrivateKey() crypto.PrivateKey
GetPrivateKey returns the private key for the user
func (*User) GetRegistration ¶
func (u *User) GetRegistration() *registration.Resource
GetRegistration returns the registration resource