- Variables
- func AllMatchingCertificates(san string) []certmagic.Certificate
- func CipherSuiteID(name string) uint16
- func CipherSuiteNameSupported(name string) bool
- func DefaultIssuers(userEmail string) []certmagic.Issuer
- func DefaultIssuersProvisioned(ctx caddy.Context) ([]certmagic.Issuer, error)
- func OrderedHTTPSRRALPN(alpnSet map[string]struct{}) []string
- func ParseCaddyfileNestedMatcherSet(d *caddyfile.Dispenser) (caddy.ModuleMap, error)
- func ProtocolName(id uint16) string
- func SupportedCipherSuites() []*tls.CipherSuite
- type ACMEIssuer
- func (ACMEIssuer) CaddyModule() caddy.ModuleInfo
- func (iss *ACMEIssuer) GetACMEIssuer() *ACMEIssuer
- func (iss *ACMEIssuer) GetRenewalInfo(ctx context.Context, cert certmagic.Certificate) (acme.RenewalInfo, error)
- func (iss *ACMEIssuer) Issue(ctx context.Context, csr *x509.CertificateRequest) (*certmagic.IssuedCertificate, error)
- func (iss *ACMEIssuer) IssuerKey() string
- func (iss *ACMEIssuer) PreCheck(ctx context.Context, names []string, interactive bool) error
- func (iss *ACMEIssuer) Provision(ctx caddy.Context) error
- func (iss *ACMEIssuer) Revoke(ctx context.Context, cert certmagic.CertificateResource, reason int) error
- func (iss *ACMEIssuer) SetConfig(cfg *certmagic.Config)
- func (iss *ACMEIssuer) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- type AutomateLoader
- type AutomationConfig
- type AutomationPolicy
- type CA
- type CertCacheOptions
- type CertKeyFilePair
- type CertKeyPEMPair
- type Certificate
- type CertificateLoader
- type CertificateProvider
- type ChainPreference
- type ChallengesConfig
- type ClientAuthentication
- type ClientCertificateVerifier
- type CombinedCAPool
- func (CombinedCAPool) CaddyModule() caddy.ModuleInfo
- func (ccp CombinedCAPool) CertPool() *x509.CertPool
- func (ccp CombinedCAPool) Certificates() []*x509.Certificate
- func (ccp *CombinedCAPool) Provision(ctx caddy.Context) error
- func (ccp *CombinedCAPool) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- type ConfigSetter
- type ConnectionMatcher
- type ConnectionPolicies
- type ConnectionPolicy
- type CustomCertSelectionPolicy
- type DNSChallengeConfig
- type ECH
- type ECHConfiguration
- type ECHDNSProvider
- type ECHDNSPublisher
- type ECHPublication
- type ECHPublisher
- type FileCAPool
- type FileLoader
- type FolderLoader
- type HTTPCertGetter
- func (hcg HTTPCertGetter) CaddyModule() caddy.ModuleInfo
- func (hcg HTTPCertGetter) GetCertificate(ctx context.Context, hello *tls.ClientHelloInfo) (*tls.Certificate, error)
- func (hcg *HTTPCertGetter) Provision(ctx caddy.Context) error
- func (hcg *HTTPCertGetter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- type HTTPCertPool
- func (HTTPCertPool) CaddyModule() caddy.ModuleInfo
- func (hcp HTTPCertPool) CertPool() *x509.CertPool
- func (hcp HTTPCertPool) Certificates() []*x509.Certificate
- func (hcp *HTTPCertPool) Provision(ctx caddy.Context) error
- func (hcp *HTTPCertPool) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- func (hcp HTTPCertPool) Validate() (err error)
- type HTTPChallengeConfig
- type HandshakeContext
- type InlineCAPool
- type InternalIssuer
- func (InternalIssuer) CaddyModule() caddy.ModuleInfo
- func (iss InternalIssuer) Issue(ctx context.Context, csr *x509.CertificateRequest) (*certmagic.IssuedCertificate, error)
- func (iss InternalIssuer) IssuerKey() string
- func (iss *InternalIssuer) Provision(ctx caddy.Context) error
- func (iss *InternalIssuer) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- type LeafCertClientAuth
- func (LeafCertClientAuth) CaddyModule() caddy.ModuleInfo
- func (l *LeafCertClientAuth) Provision(ctx caddy.Context) error
- func (l *LeafCertClientAuth) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- func (l LeafCertClientAuth) VerifyClientCertificate(rawCerts [][]byte, _ [][]*x509.Certificate) error
- type LeafCertificateLoader
- type LeafFileLoader
- type LeafFolderLoader
- type LeafPEMLoader
- type LeafStorageLoader
- type MatchLocalIP
- type MatchRegexp
- type MatchRemoteIP
- type MatchServerName
- type MatchServerNameRE
- type OnDemandConfig
- type OnDemandPermission
- type PEMLoader
- type PKIIntermediateCAPool
- func (PKIIntermediateCAPool) CaddyModule() caddy.ModuleInfo
- func (p PKIIntermediateCAPool) CertPool() *x509.CertPool
- func (p PKIIntermediateCAPool) Certificates() []*x509.Certificate
- func (p *PKIIntermediateCAPool) Provision(ctx caddy.Context) error
- func (pic *PKIIntermediateCAPool) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- type PKIRootCAPool
- type PermissionByHTTP
- type PublicKeyAlgorithm
- type PublishECHConfigListErrors
- type STEKProvider
- type SessionTicketService
- type StorageLoader
- type StoragePool
- type SystemCAPool
- type TLS
- func (t *TLS) AddAutomationPolicy(ap *AutomationPolicy) error
- func (TLS) CaddyModule() caddy.ModuleInfo
- func (t *TLS) Cleanup() error
- func (t *TLS) HandleHTTPChallenge(w http.ResponseWriter, r *http.Request) bool
- func (t *TLS) HasCertificateForSubject(subject string) bool
- func (t *TLS) Manage(subjects map[string]struct{}) error
- func (t *TLS) Provision(ctx caddy.Context) error
- func (t *TLS) RegisterServerNames(dnsNames, alpnValues []string)
- func (t *TLS) Start() error
- func (t *TLS) Stop() error
- func (t *TLS) Validate() error
- type TLSALPNChallengeConfig
- type TLSConfig
- type Tailscale
- type ZeroSSLIssuer
- func (*ZeroSSLIssuer) CaddyModule() caddy.ModuleInfo
- func (iss *ZeroSSLIssuer) Issue(ctx context.Context, csr *x509.CertificateRequest) (*certmagic.IssuedCertificate, error)
- func (iss *ZeroSSLIssuer) IssuerKey() string
- func (iss *ZeroSSLIssuer) Provision(ctx caddy.Context) error
- func (iss *ZeroSSLIssuer) Revoke(ctx context.Context, cert certmagic.CertificateResource, reason int) error
- func (iss *ZeroSSLIssuer) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
This section is empty.
ErrPermissionDenied is an error that should be wrapped or returned when the configured permission module does not allow a certificate to be issued, to distinguish that from other errors such as connection failure.
SupportedCurves is the unordered map of supported curves or key exchange mechanisms ("curves" traditionally). https://golang.org/pkg/crypto/tls/#CurveID
SupportedProtocols is a map of supported protocols.
AllMatchingCertificates returns the list of all certificates in the cache which could be used to satisfy the given SAN.
CipherSuiteID returns the ID of the cipher suite associated with the given name, or 0 if the name is not recognized/supported.
CipherSuiteNameSupported returns true if name is a supported cipher suite.
DefaultIssuers returns empty Issuers (not provisioned) to be used as defaults. This function is experimental and has no compatibility promises.
DefaultIssuersProvisioned returns empty but provisioned default Issuers from DefaultIssuers(). This function is experimental and has no compatibility promises.
OrderedHTTPSRRALPN returns the HTTPS RR ALPN values in preferred order.
ParseCaddyfileNestedMatcherSet parses the Caddyfile tokens for a nested matcher set, and returns its raw module map value.
ProtocolName returns the standard name for the passed protocol version ID (e.g. "TLS1.3") or a fallback representation of the ID value if the version is not supported.
SupportedCipherSuites returns a list of all the cipher suites Caddy supports. The list is NOT ordered by security preference.
type ACMEIssuer struct {
CA string `json:"ca,omitempty"`
TestCA string `json:"test_ca,omitempty"`
Email string `json:"email,omitempty"`
Profile string `json:"profile,omitempty"`
AccountKey string `json:"account_key,omitempty"`
ExternalAccount *acme.EAB `json:"external_account,omitempty"`
ACMETimeout caddy.Duration `json:"acme_timeout,omitempty"`
Challenges *ChallengesConfig `json:"challenges,omitempty"`
TrustedRootsPEMFiles []string `json:"trusted_roots_pem_files,omitempty"`
PreferredChains *ChainPreference `json:"preferred_chains,omitempty"`
CertificateLifetime caddy.Duration `json:"certificate_lifetime,omitempty"`
NetworkProxyRaw json.RawMessage `json:"network_proxy,omitempty" caddy:"namespace=caddy.network_proxy inline_key=from"`
}
ACMEIssuer manages certificates using the ACME protocol (RFC 8555).
CaddyModule returns the Caddy module information.
func (iss *ACMEIssuer) GetACMEIssuer() *ACMEIssuer
GetACMEIssuer returns iss. This is useful when other types embed ACMEIssuer, because type-asserting them to *ACMEIssuer will fail, but type-asserting them to an interface with only this method will succeed, and will still allow the embedded ACMEIssuer to be accessed and manipulated.
GetRenewalInfo wraps the underlying GetRenewalInfo method and satisfies the CertMagic interface for ARI support.
Issue obtains a certificate for the given csr.
IssuerKey returns the unique issuer key for the configured CA endpoint.
PreCheck implements the certmagic.PreChecker interface.
Provision sets up iss.
Revoke revokes the given certificate.
SetConfig sets the associated certmagic config for this issuer. This is required because ACME needs values from the config in order to solve the challenges during issuance. This implements the ConfigSetter interface.
UnmarshalCaddyfile deserializes Caddyfile tokens into iss.
... acme [<directory_url>] {
dir <directory_url>
test_dir <test_directory_url>
email <email>
profile <profile_name>
timeout <duration>
disable_http_challenge
disable_tlsalpn_challenge
alt_http_port <port>
alt_tlsalpn_port <port>
eab <key_id> <mac_key>
trusted_roots <pem_files...>
dns <provider_name> [<options>]
propagation_delay <duration>
propagation_timeout <duration>
resolvers <dns_servers...>
dns_ttl <duration>
dns_challenge_override_domain <domain>
preferred_chains [smallest] {
root_common_name <common_names...>
any_common_name <common_names...>
}
}
AutomateLoader will automatically manage certificates for the names in the list, including obtaining and renewing certificates. Automated certificates are managed according to their matching automation policy, configured elsewhere in this app.
Technically, this is a no-op certificate loader module that is treated as a special case: it uses this app's automation features to load certificates for the list of hostnames, rather than loading certificates manually. But the end result is the same: certificates for these subject names will be loaded into the in-memory cache and may then be used.
CaddyModule returns the Caddy module information.
type AutomationConfig struct {
Policies []*AutomationPolicy `json:"policies,omitempty"`
OnDemand *OnDemandConfig `json:"on_demand,omitempty"`
OCSPCheckInterval caddy.Duration `json:"ocsp_interval,omitempty"`
RenewCheckInterval caddy.Duration `json:"renew_interval,omitempty"`
StorageCleanInterval caddy.Duration `json:"storage_clean_interval,omitempty"`
}
AutomationConfig governs the automated management of TLS certificates.
type AutomationPolicy struct {
SubjectsRaw []string `json:"subjects,omitempty"`
IssuersRaw []json.RawMessage `json:"issuers,omitempty" caddy:"namespace=tls.issuance inline_key=module"`
ManagersRaw []json.RawMessage `json:"get_certificate,omitempty" caddy:"namespace=tls.get_certificate inline_key=via"`
MustStaple bool `json:"must_staple,omitempty"`
RenewalWindowRatio float64 `json:"renewal_window_ratio,omitempty"`
KeyType string `json:"key_type,omitempty"`
StorageRaw json.RawMessage `json:"storage,omitempty" caddy:"namespace=caddy.storage inline_key=module"`
OnDemand bool `json:"on_demand,omitempty"`
ReusePrivateKeys bool `json:"reuse_private_keys,omitempty"`
DisableOCSPStapling bool `json:"disable_ocsp_stapling,omitempty"`
OCSPOverrides map[string]string `json:"ocsp_overrides,omitempty"`
Issuers []certmagic.Issuer `json:"-"`
Managers []certmagic.Manager `json:"-"`
}
AutomationPolicy designates the policy for automating the management (obtaining, renewal, and revocation) of managed TLS certificates.
An AutomationPolicy value is not valid until it has been provisioned; use the `AddAutomationPolicy()` method on the TLS app to properly provision a new policy.
func (ap *AutomationPolicy) AllInternalSubjects() bool
AllInternalSubjects returns true if all the subjects on this policy are internal.
func (ap *AutomationPolicy) IsProvisioned() bool
IsProvisioned reports whether the automation policy has been provisioned. A provisioned policy has an initialized CertMagic instance (i.e. ap.magic != nil).
func (ap *AutomationPolicy) Provision(tlsApp *TLS) error
Provision sets up ap and builds its underlying CertMagic config.
func (ap *AutomationPolicy) RebuildCertMagic(tlsApp *TLS) error
RebuildCertMagic rebuilds the policy's CertMagic configuration from the policy's already-populated fields (Issuers, Managers, storage, etc.) and replaces the internal CertMagic instance. This is a lightweight alternative to calling Provision because it does not re-provision modules or re-run module Provision; instead, it constructs a new certmagic.Config and calls SetConfig on issuers so they receive updated templates (for example, alternate HTTP/TLS ports supplied by the HTTP app). RebuildCertMagic should only be called when the policy's required fields are already populated.
Subjects returns the list of subjects with all placeholders replaced.
The interface to be implemented by all guest modules part of the namespace 'tls.ca_pool.source.'
type CertCacheOptions struct {
Capacity int `json:"capacity,omitempty"`
}
CertCacheOptions configures the certificate cache.
type CertKeyFilePair struct {
Certificate string `json:"certificate"`
Key string `json:"key"`
Format string `json:"format,omitempty"`
Tags []string `json:"tags,omitempty"`
}
CertKeyFilePair pairs certificate and key file names along with their encoding format so that they can be loaded from disk.
type CertKeyPEMPair struct {
CertificatePEM string `json:"certificate"`
KeyPEM string `json:"key"`
Tags []string `json:"tags,omitempty"`
}
CertKeyPEMPair pairs certificate and key PEM blocks.
Certificate is a TLS certificate, optionally associated with arbitrary tags.
type CertificateLoader interface {
LoadCertificates() ([]Certificate, error)
}
CertificateLoader is a type that can load certificates. Certificates can optionally be associated with tags.
CertificateProvider is an optional interface that CA pool sources can implement to expose their underlying certificates for combining.
type ChainPreference struct {
Smallest *bool `json:"smallest,omitempty"`
RootCommonName []string `json:"root_common_name,omitempty"`
AnyCommonName []string `json:"any_common_name,omitempty"`
}
ChainPreference describes the client's preferred certificate chain, useful if the CA offers alternate chains. The first matching chain will be selected.
type ChallengesConfig struct {
HTTP *HTTPChallengeConfig `json:"http,omitempty"`
TLSALPN *TLSALPNChallengeConfig `json:"tls-alpn,omitempty"`
DNS *DNSChallengeConfig `json:"dns,omitempty"`
BindHost string `json:"bind_host,omitempty"`
Distributed *bool `json:"distributed,omitempty"`
}
ChallengesConfig configures the ACME challenges.
type ClientAuthentication struct {
CARaw json.RawMessage `json:"ca,omitempty" caddy:"namespace=tls.ca_pool.source inline_key=provider"`
TrustedCACerts []string `json:"trusted_ca_certs,omitempty"`
TrustedCACertPEMFiles []string `json:"trusted_ca_certs_pem_files,omitempty"`
TrustedLeafCerts []string `json:"trusted_leaf_certs,omitempty"`
VerifiersRaw []json.RawMessage `json:"verifiers,omitempty" caddy:"namespace=tls.client_auth.verifier inline_key=verifier"`
Mode string `json:"mode,omitempty"`
}
ClientAuthentication configures TLS client auth.
func (clientauth ClientAuthentication) Active() bool
Active returns true if clientauth has an actionable configuration.
ConfigureTLSConfig sets up cfg to enforce clientauth's configuration.
UnmarshalCaddyfile parses the Caddyfile segment to set up the client authentication. Syntax:
client_auth {
mode [request|require|verify_if_given|require_and_verify]
trust_pool <module> {
...
}
verifier <module>
}
If `mode` is not provided, it defaults to `require_and_verify` if `trust_pool` is provided. Otherwise, it defaults to `require`.
type ClientCertificateVerifier interface {
VerifyClientCertificate(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error
}
ClientCertificateVerifier is a type which verifies client certificates. It is called during verifyPeerCertificate in the TLS handshake.
type CombinedCAPool struct {
SourcesRaw []json.RawMessage `json:"sources,omitempty" caddy:"namespace=tls.ca_pool.source inline_key=provider"`
}
The `combined` pool type merges multiple pools. The `sources` pools must implement the `CertificateProvider` interface, which allows them to export their certificate set.
Note: SystemCAPool does not implement CertificateProvider because x509.SystemCertPool() doesn't expose its certificates, so it cannot be used as a source in CombinedCAPool.
CaddyModule implements caddy.Module.
CertPool implements CA.
Certificates implements CertificateProvider.
Provision implements caddy.Provisioner.
Syntax:
trust_pool combined {
source <module_name> {
<module_config>
}
}
The 'source' directive can be specified multiple times. Sources that don't implement CertificateProvider (like 'system') cannot be combined.
ConfigSetter is implemented by certmagic.Issuers that need access to a parent certmagic.Config as part of their provisioning phase. For example, the ACMEIssuer requires a config so it can access storage and the cache to solve ACME challenges.
ConnectionMatcher is a type which matches TLS handshakes.
type ConnectionPolicies []*ConnectionPolicy
ConnectionPolicies govern the establishment of TLS connections. It is an ordered group of connection policies; the first matching policy will be used to configure TLS connections at handshake-time.
Provision sets up each connection policy. It should be called during the Validate() phase, after the TLS app (if any) is already set up.
TLSConfig returns a standard-lib-compatible TLS configuration which selects the first matching policy based on the ClientHello.
type ConnectionPolicy struct {
MatchersRaw caddy.ModuleMap `json:"match,omitempty" caddy:"namespace=tls.handshake_match"`
CertSelection *CustomCertSelectionPolicy `json:"certificate_selection,omitempty"`
CipherSuites []string `json:"cipher_suites,omitempty"`
Curves []string `json:"curves,omitempty"`
ALPN []string `json:"alpn,omitempty"`
ProtocolMin string `json:"protocol_min,omitempty"`
ProtocolMax string `json:"protocol_max,omitempty"`
Drop bool `json:"drop,omitempty"`
ClientAuthentication *ClientAuthentication `json:"client_authentication,omitempty"`
DefaultSNI string `json:"default_sni,omitempty"`
FallbackSNI string `json:"fallback_sni,omitempty"`
InsecureSecretsLog string `json:"insecure_secrets_log,omitempty"`
HandshakeContextRaw json.RawMessage `json:"handshake_context,omitempty" caddy:"namespace=tls.context inline_key=module"`
TLSConfig *tls.Config `json:"-"`
}
ConnectionPolicy specifies the logic for handling a TLS handshake. An empty policy is valid; safe and sensible defaults will be used.
func (p ConnectionPolicy) SettingsEmpty() bool
SettingsEmpty returns true if p's settings (fields except the matchers) are all empty/unset.
SettingsEqual returns true if p's settings (fields except the matchers) are the same as q.
UnmarshalCaddyfile sets up the ConnectionPolicy from Caddyfile tokens. Syntax:
connection_policy {
alpn <values...>
cert_selection {
...
}
ciphers <cipher_suites...>
client_auth {
...
}
curves <curves...>
default_sni <server_name>
match {
...
}
protocols <min> [<max>]
# EXPERIMENTAL:
drop
fallback_sni <server_name>
insecure_secrets_log <log_file>
}
type CustomCertSelectionPolicy struct {
SerialNumber []bigInt `json:"serial_number,omitempty"`
SubjectOrganization []string `json:"subject_organization,omitempty"`
PublicKeyAlgorithm PublicKeyAlgorithm `json:"public_key_algorithm,omitempty"`
AnyTag []string `json:"any_tag,omitempty"`
AllTags []string `json:"all_tags,omitempty"`
}
CustomCertSelectionPolicy represents a policy for selecting the certificate used to complete a handshake when there may be multiple options. All fields specified must match the candidate certificate for it to be chosen. This was needed to solve https://github.com/caddyserver/caddy/issues/2588.
SelectCertificate implements certmagic.CertificateSelector. It only chooses a certificate that at least meets the criteria in p. It then chooses the first non-expired certificate that is compatible with the client. If none are valid, it chooses the first viable candidate anyway.
UnmarshalCaddyfile sets up the CustomCertSelectionPolicy from Caddyfile tokens. Syntax:
cert_selection {
all_tags <values...>
any_tag <values...>
public_key_algorithm <dsa|ecdsa|rsa>
serial_number <big_integers...>
subject_organization <values...>
}
type DNSChallengeConfig struct {
ProviderRaw json.RawMessage `json:"provider,omitempty" caddy:"namespace=dns.providers inline_key=name"`
TTL caddy.Duration `json:"ttl,omitempty"`
PropagationDelay caddy.Duration `json:"propagation_delay,omitempty"`
PropagationTimeout caddy.Duration `json:"propagation_timeout,omitempty"`
Resolvers []string `json:"resolvers,omitempty"`
OverrideDomain string `json:"override_domain,omitempty"`
}
DNSChallengeConfig configures the ACME DNS challenge.
NOTE: This API is still experimental and is subject to change.
type ECH struct {
Configs []ECHConfiguration `json:"configs,omitempty"`
Publication []*ECHPublication `json:"publication,omitempty"`
}
ECH enables Encrypted ClientHello (ECH) and configures its management.
ECH helps protect site names (also called "server names" or "domain names" or "SNI"), which are normally sent over plaintext when establishing a TLS connection. With ECH, the true ClientHello is encrypted and wrapped by an "outer" ClientHello that uses a more generic, shared server name that is publicly known.
Clients need to know which public name (and other parameters) to use when connecting to a site with ECH, and the methods for this vary; however, major browsers support reading ECH configurations from DNS records (which is typically only secure when DNS-over-HTTPS or DNS-over-TLS is enabled in the client). Caddy has the ability to automatically publish ECH configs to DNS records if a DNS provider is configured either in the TLS app or with each individual publication config object. (Requires a custom build with a DNS provider module.)
ECH requires at least TLS 1.3, so any TLS connection policies with ECH applied will automatically upgrade the minimum TLS version to 1.3, even if configured to a lower version.
EXPERIMENTAL: Subject to change.
Provision loads or creates ECH configs and returns outer names (for certificate management), but does not publish any ECH configs. The DNS module is used as a default for later publishing if needed.
type ECHConfiguration struct {
PublicName string `json:"public_name"`
}
ECH represents an Encrypted ClientHello configuration.
EXPERIMENTAL: Subject to change.
ECHDNSProvider can service DNS entries for ECH purposes.
type ECHDNSPublisher struct {
ProviderRaw json.RawMessage `json:"provider,omitempty" caddy:"namespace=dns.providers inline_key=name"`
}
ECHDNSPublisher configures how to publish an ECH configuration to DNS records for the specified domains.
EXPERIMENTAL: Subject to change.
CaddyModule returns the Caddy module information.
PublishECHConfigList publishes the given ECH config list (as binary) to the given DNS names. If there is an error, it may be of type PublishECHConfigListErrors, detailing potentially multiple errors keyed by associated innerName.
PublisherKey returns the name of the DNS provider module. We intentionally omit specific provider configuration (or a hash thereof, since the config is likely sensitive, potentially containing an API key) because it is unlikely that specific configuration, such as an API key, is relevant to unique key use as an ECH config publisher.
type ECHPublication struct {
Configs []string `json:"configs,omitempty"`
Domains []string `json:"domains,omitempty"`
PublishersRaw caddy.ModuleMap `json:"publishers,omitempty" caddy:"namespace=tls.ech.publishers"`
}
ECHPublication configures publication of ECH config(s). It pairs a list of ECH configs with the list of domains they are assigned to protect, and describes how to publish those configs for those domains.
Most servers will have only a single publication config, unless their domains are spread across multiple DNS providers or require different methods of publication.
EXPERIMENTAL: Subject to change.
ECHPublisher is an interface for publishing ECHConfigList values so that they can be used by clients.
type FileCAPool struct {
TrustedCACertPEMFiles []string `json:"pem_files,omitempty"`
}
FileCAPool generates trusted root certificates pool from the designated DER and PEM file
CaddyModule implements caddy.Module.
Certificates implements CertificateProvider.
Loads and decodes the DER and pem files to generate the certificate pool
Syntax:
trust_pool file [<pem_file>...] {
pem_file <pem_file>...
}
The 'pem_file' directive can be specified multiple times.
type FileLoader []CertKeyFilePair
FileLoader loads certificates and their associated keys from disk.
CaddyModule returns the Caddy module information.
func (fl FileLoader) LoadCertificates() ([]Certificate, error)
LoadCertificates returns the certificates to be loaded by fl.
Provision implements caddy.Provisioner.
FolderLoader loads certificates and their associated keys from disk by recursively walking the specified directories, looking for PEM files which contain both a certificate and a key.
CaddyModule returns the Caddy module information.
func (fl FolderLoader) LoadCertificates() ([]Certificate, error)
LoadCertificates loads all the certificates+keys in the directories listed in fl from all files ending with .pem. This method of loading certificates expects the certificate and key to be bundled into the same file.
Provision implements caddy.Provisioner.
type HTTPCertGetter struct {
URL string `json:"url,omitempty"`
}
HTTPCertGetter can get a certificate via HTTP(S) request.
CaddyModule returns the Caddy module information.
UnmarshalCaddyfile deserializes Caddyfile tokens into ts.
... http <url>
type HTTPCertPool struct {
Endpoints []string `json:"endpoints,omitempty"`
TLS *TLSConfig `json:"tls,omitempty"`
}
The HTTPCertPool fetches the trusted root certificates from HTTP(S) endpoints. The TLS connection properties can be customized, including custom trusted root certificate. One example usage of this module is to get the trusted certificates from another Caddy instance that is running the PKI app and ACME server.
CaddyModule implements caddy.Module.
CertPool return the certificate pool generated from the HTTP responses
Certificates implements CertificateProvider.
Provision implements caddy.Provisioner.
Syntax:
trust_pool http [<endpoints...>] {
endpoints <endpoints...>
tls <tls_config>
}
tls_config:
ca <ca_module> insecure_skip_verify handshake_timeout <duration> server_name <name> renegotiation <never|once|freely> <ca_module> is the name of the CA module to source the trust
certificate pool and follows the syntax of the named CA module.
func (hcp HTTPCertPool) Validate() (err error)
report error if the endpoints are not valid URLs
type HTTPChallengeConfig struct {
Disabled bool `json:"disabled,omitempty"`
AlternatePort int `json:"alternate_port,omitempty"`
}
HTTPChallengeConfig configures the ACME HTTP challenge.
type InlineCAPool struct {
TrustedCACerts []string `json:"trusted_ca_certs,omitempty"`
}
InlineCAPool is a certificate authority pool provider coming from a DER-encoded certificates in the config
CaddyModule implements caddy.Module.
CertPool implements CA.
Certificates implements CertificateProvider.
Provision implements caddy.Provisioner.
Syntax:
trust_pool inline {
trust_der <base64_der_cert>...
}
The 'trust_der' directive can be specified multiple times.
type InternalIssuer struct {
CA string `json:"ca,omitempty"`
Lifetime caddy.Duration `json:"lifetime,omitempty"`
SignWithRoot bool `json:"sign_with_root,omitempty"`
}
InternalIssuer is a certificate issuer that generates certificates internally using a locally-configured CA which can be customized using the `pki` app.
CaddyModule returns the Caddy module information.
Issue issues a certificate to satisfy the CSR.
IssuerKey returns the unique issuer key for the configured CA endpoint.
Provision sets up the issuer.
UnmarshalCaddyfile deserializes Caddyfile tokens into iss.
... internal {
ca <name>
lifetime <duration>
sign_with_root
}
type LeafCertClientAuth struct {
LeafCertificateLoadersRaw []json.RawMessage `json:"leaf_certs_loaders,omitempty" caddy:"namespace=tls.leaf_cert_loader inline_key=loader"`
}
LeafCertClientAuth verifies the client's leaf certificate.
CaddyModule returns the Caddy module information.
UnmarshalCaddyfile implements caddyfile.Unmarshaler.
LeafCertificateLoader is a type that loads the trusted leaf certificates for the tls.leaf_cert_loader modules
type LeafFileLoader struct {
Files []string `json:"files,omitempty"`
}
LeafFileLoader loads leaf certificates from disk.
CaddyModule returns the Caddy module information.
LoadLeafCertificates returns the certificates to be loaded by fl.
Provision implements caddy.Provisioner.
UnmarshalCaddyfile implements caddyfile.Unmarshaler.
type LeafFolderLoader struct {
Folders []string `json:"folders,omitempty"`
}
LeafFolderLoader loads certificates from disk by recursively walking the specified directories, looking for PEM files which contain a certificate.
CaddyModule returns the Caddy module information.
LoadLeafCertificates loads all the leaf certificates in the directories listed in fl from all files ending with .pem.
Provision implements caddy.Provisioner.
UnmarshalCaddyfile implements caddyfile.Unmarshaler.
type LeafPEMLoader struct {
Certificates []string `json:"certificates,omitempty"`
}
LeafPEMLoader loads leaf certificates by decoding their PEM blocks directly. This has the advantage of not needing to store them on disk at all.
CaddyModule returns the Caddy module information.
LoadLeafCertificates returns the certificates contained in pl.
Provision implements caddy.Provisioner.
UnmarshalCaddyfile implements caddyfile.Unmarshaler.
type LeafStorageLoader struct {
Certificates []string `json:"certificates,omitempty"`
StorageRaw json.RawMessage `json:"storage,omitempty" caddy:"namespace=caddy.storage inline_key=module"`
}
LeafStorageLoader loads leaf certificates from the globally configured storage module.
CaddyModule returns the Caddy module information.
LoadLeafCertificates returns the certificates to be loaded by sl.
Provision loads the storage module for sl.
type MatchLocalIP struct {
Ranges []string `json:"ranges,omitempty"`
}
MatchLocalIP matches based on the IP address of the interface receiving the connection. Specific IPs or CIDR ranges can be specified.
CaddyModule returns the Caddy module information.
Match matches hello based on the connection's remote IP.
Provision parses m's IP ranges, either from IP or CIDR expressions.
UnmarshalCaddyfile sets up the MatchLocalIP from Caddyfile tokens. Syntax:
local_ip <ranges...>
MatchRegexp is an embeddable type for matching using regular expressions. It adds placeholders to the request's replacer. In fact, it is a copy of caddyhttp.MatchRegexp with a local replacer prefix and placeholders support in a regular expression pattern.
Match returns true if input matches the compiled regular expression in m. It sets values on the replacer repl associated with capture groups, using the given scope (namespace).
Provision compiles the regular expression which may include placeholders.
UnmarshalCaddyfile implements caddyfile.Unmarshaler.
Validate ensures mre is set up correctly.
type MatchRemoteIP struct {
Ranges []string `json:"ranges,omitempty"`
NotRanges []string `json:"not_ranges,omitempty"`
}
MatchRemoteIP matches based on the remote IP of the connection. Specific IPs or CIDR ranges can be specified.
Note that IPs can sometimes be spoofed, so do not rely on this as a replacement for actual authentication.
CaddyModule returns the Caddy module information.
Match matches hello based on the connection's remote IP.
Provision parses m's IP ranges, either from IP or CIDR expressions.
UnmarshalCaddyfile sets up the MatchRemoteIP from Caddyfile tokens. Syntax:
remote_ip <ranges...>
Note: IPs and CIDRs prefixed with ! symbol are treated as not_ranges
MatchServerName matches based on SNI. Names in this list may use left-most-label wildcards, similar to wildcard certificates.
CaddyModule returns the Caddy module information.
Match matches hello based on SNI.
UnmarshalCaddyfile sets up the MatchServerName from Caddyfile tokens. Syntax:
sni <domains...>
type MatchServerNameRE struct{ MatchRegexp }
MatchServerNameRE matches based on SNI using a regular expression.
CaddyModule returns the Caddy module information.
Match matches hello based on SNI using a regular expression.
type OnDemandConfig ¶
type OnDemandConfig struct {
Ask string `json:"ask,omitempty"`
PermissionRaw json.RawMessage `json:"permission,omitempty" caddy:"namespace=tls.permission inline_key=module"`
}
OnDemandConfig configures on-demand TLS, for obtaining needed certificates at handshake-time. Because this feature can easily be abused, Caddy must ask permission to your application whether a particular domain is allowed to have a certificate issued for it.
type OnDemandPermission ¶ added in v2.8.0
OnDemandPermission is a type that can give permission for whether a certificate should be allowed to be obtained or loaded from storage on-demand. EXPERIMENTAL: This API is experimental and subject to change.
type PEMLoader []CertKeyPEMPair
PEMLoader loads certificates and their associated keys by decoding their PEM blocks directly. This has the advantage of not needing to store them on disk at all.
CaddyModule returns the Caddy module information.
func (pl PEMLoader) LoadCertificates() ([]Certificate, error)
LoadCertificates returns the certificates contained in pl.
Provision implements caddy.Provisioner.
type PKIIntermediateCAPool struct {
Authority []string `json:"authority,omitempty"`
}
PKIIntermediateCAPool extracts the trusted intermediate certificates from Caddy's native 'pki' app
CaddyModule implements caddy.Module.
return the certificate pool generated with intermediate certificates from the PKI app
Certificates implements CertificateProvider.
Loads the PKI app and loads the intermediate certificates into the certificate pool
Syntax:
trust_pool pki_intermediate [<ca_name>...] {
authority <ca_name>...
}
The 'authority' directive can be specified multiple times.
type PKIRootCAPool struct {
Authority []string `json:"authority,omitempty"`
}
PKIRootCAPool extracts the trusted root certificates from Caddy's native 'pki' app
CaddyModule implements caddy.Module.
return the certificate pool generated with root certificates from the PKI app
Certificates implements CertificateProvider.
Loads the PKI app and load the root certificates into the certificate pool
Syntax:
trust_pool pki_root [<ca_name>...] {
authority <ca_name>...
}
The 'authority' directive can be specified multiple times.
type PermissionByHTTP struct {
Endpoint string `json:"endpoint"`
}
PermissionByHTTP determines permission for a TLS certificate by making a request to an HTTP endpoint.
CaddyModule returns the Caddy module information.
UnmarshalCaddyfile implements caddyfile.Unmarshaler.
PublicKeyAlgorithm is a JSON-unmarshalable wrapper type.
UnmarshalJSON satisfies json.Unmarshaler.
PublishECHConfigListErrors is returned by ECHPublishers to describe one or more errors publishing an ECH config list from PublishECHConfigList. A non-nil, empty value of this type should never be returned. nolint:errname // The linter wants "Error" convention, but this is a multi-error type.
type STEKProvider interface {
Initialize(config *SessionTicketService) ([][32]byte, error)
Next(doneChan <-chan struct{}) (keysChan <-chan [][32]byte)
}
STEKProvider is a type that can provide session ticket ephemeral keys (STEKs).
type SessionTicketService struct {
KeySource json.RawMessage `json:"key_source,omitempty" caddy:"namespace=tls.stek inline_key=provider"`
RotationInterval caddy.Duration `json:"rotation_interval,omitempty"`
MaxKeys int `json:"max_keys,omitempty"`
DisableRotation bool `json:"disable_rotation,omitempty"`
Disabled bool `json:"disabled,omitempty"`
}
SessionTicketService configures and manages TLS session tickets.
RotateSTEKs rotates the keys in keys by producing a new key and eliding the oldest one. The new slice of keys is returned.
type StorageLoader struct {
Pairs []CertKeyFilePair `json:"pairs,omitempty"`
}
StorageLoader loads certificates and their associated keys from the globally configured storage module.
CaddyModule returns the Caddy module information.
func (sl StorageLoader) LoadCertificates() ([]Certificate, error)
LoadCertificates returns the certificates to be loaded by sl.
Provision loads the storage module for sl.
type StoragePool struct {
StorageRaw json.RawMessage `json:"storage,omitempty" caddy:"namespace=caddy.storage inline_key=module"`
PEMKeys []string `json:"pem_keys,omitempty"`
}
StoragePool extracts the trusted certificates root from Caddy storage
CaddyModule implements caddy.Module.
Certificates implements CertificateProvider.
Provision implements caddy.Provisioner.
Syntax:
trust_pool storage [<storage_keys>...] {
storage <storage_module>
keys <storage_keys>...
}
The 'keys' directive can be specified multiple times. The'storage' directive is optional and defaults to the default storage module.
type SystemCAPool struct {
}
SystemCAPool obtains the trusted root certificates from the system's certificate pool using x509.SystemCertPool()
CaddyModule implements caddy.Module.
CertPool implements CA.
Provision implements caddy.Provisioner.
type TLS struct {
CertificatesRaw caddy.ModuleMap `json:"certificates,omitempty" caddy:"namespace=tls.certificates"`
Automation *AutomationConfig `json:"automation,omitempty"`
SessionTickets *SessionTicketService `json:"session_tickets,omitempty"`
Cache *CertCacheOptions `json:"cache,omitempty"`
DisableOCSPStapling bool `json:"disable_ocsp_stapling,omitempty"`
DisableStorageCheck bool `json:"disable_storage_check,omitempty"`
DisableStorageClean bool `json:"disable_storage_clean,omitempty"`
EncryptedClientHello *ECH `json:"encrypted_client_hello,omitempty"`
DNSRaw json.RawMessage `json:"dns,omitempty" caddy:"namespace=dns.providers inline_key=name"`
Resolvers []string `json:"resolvers,omitempty"`
}
TLS provides TLS facilities including certificate loading and management, client auth, and more.
func (t *TLS) AddAutomationPolicy(ap *AutomationPolicy) error
AddAutomationPolicy provisions and adds ap to the list of the app's automation policies. If an existing automation policy exists that has fewer hosts in its list than ap does, ap will be inserted before that other policy (this helps ensure that ap will be prioritized/chosen over, say, a catch-all policy).
CaddyModule returns the Caddy module information.
Cleanup frees up resources allocated during Provision.
func (*TLS) HandleHTTPChallenge ¶
HandleHTTPChallenge ensures that the ACME HTTP challenge or ZeroSSL HTTP validation request is handled for the certificate named by r.Host, if it is an HTTP challenge request. It requires that the automation policy for r.Host has an issuer that implements GetACMEIssuer() or is a *ZeroSSLIssuer.
Manage immediately begins managing subjects according to the matching automation policy. The subjects are given in a map to prevent duplication and also because quick lookups are needed to assess wildcard coverage, if any, depending on certain config parameters (with lots of subjects, computing wildcard coverage over a slice can be highly inefficient).
Provision sets up the configuration for the TLS app.
RegisterServerNames registers the provided DNS names with the TLS app and associates them with the given HTTPS RR ALPN values, if any. This is currently used to auto-publish Encrypted ClientHello (ECH) configurations, if enabled. Use of this function by apps using the TLS app removes the need for the user to redundantly specify domain names in their configuration. This function separates hostname and port, keeping only the hostname, and filters IP addresses which can't be used with ECH.
EXPERIMENTAL: This function and its semantics/behavior are subject to change.
Start activates the TLS module.
Stop stops the TLS module and cleans up any allocations.
type TLSALPNChallengeConfig struct {
Disabled bool `json:"disabled,omitempty"`
AlternatePort int `json:"alternate_port,omitempty"`
}
TLSALPNChallengeConfig configures the ACME TLS-ALPN challenge.
type TLSConfig struct {
CARaw json.RawMessage `json:"ca,omitempty" caddy:"namespace=tls.ca_pool.source inline_key=provider"`
InsecureSkipVerify bool `json:"insecure_skip_verify,omitempty"`
HandshakeTimeout caddy.Duration `json:"handshake_timeout,omitempty"`
ServerName string `json:"server_name,omitempty"`
Renegotiation string `json:"renegotiation,omitempty"`
}
TLSConfig holds configuration related to the TLS configuration for the transport/client.
type Tailscale struct {
}
Tailscale is a module that can get certificates from the local Tailscale process.
CaddyModule returns the Caddy module information.
UnmarshalCaddyfile deserializes Caddyfile tokens into ts.
... tailscale
type ZeroSSLIssuer struct {
APIKey string `json:"api_key,omitempty"`
ValidityDays int `json:"validity_days,omitempty"`
ListenHost string `json:"listen_host,omitempty"`
AlternateHTTPPort int `json:"alternate_http_port,omitempty"`
CNAMEValidation *DNSChallengeConfig `json:"cname_validation,omitempty"`
}
ZeroSSLIssuer uses the ZeroSSL API to get certificates. Note that this is distinct from ZeroSSL's ACME endpoint. To use ZeroSSL's ACME endpoint, use the ACMEIssuer configured with ZeroSSL's ACME directory endpoint.
CaddyModule returns the Caddy module information.
Issue obtains a certificate for the given csr.
IssuerKey returns the unique issuer key for the configured CA endpoint.
Provision sets up the issuer.
Revoke revokes the given certificate.
UnmarshalCaddyfile deserializes Caddyfile tokens into iss.
... zerossl <api_key> {
validity_days <days>
alt_http_port <port>
dns <provider_name> ...
propagation_delay <duration>
propagation_timeout <duration>
resolvers <list...>
dns_ttl <duration>
}