mirror of
https://github.com/caddyserver/caddy.git
synced 2025-11-10 16:46:56 -05:00
caddytls: Fixes regarding internal-named domains, issuer configs
Should address #7147
This commit is contained in:
parent
895b56063a
commit
c3a41434e4
@ -459,7 +459,8 @@ func (st ServerType) buildTLSApp(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if there are any global options set for issuers (ACME ones in particular), make sure they
|
// if there are any global options set for issuers (ACME ones in particular), make sure they
|
||||||
// take effect in every automation policy that does not have any issuers
|
// take effect in every automation policy that does not have any issuers, by creating one or
|
||||||
|
// more issuers to be iterated in the next step below
|
||||||
if tlsApp.Automation != nil {
|
if tlsApp.Automation != nil {
|
||||||
globalEmail := options["email"]
|
globalEmail := options["email"]
|
||||||
globalACMECA := options["acme_ca"]
|
globalACMECA := options["acme_ca"]
|
||||||
@ -467,19 +468,20 @@ func (st ServerType) buildTLSApp(
|
|||||||
_, globalACMEDNS := options["acme_dns"] // can be set to nil (to use globally-defined "dns" value instead), but it is still set
|
_, globalACMEDNS := options["acme_dns"] // can be set to nil (to use globally-defined "dns" value instead), but it is still set
|
||||||
globalACMEEAB := options["acme_eab"]
|
globalACMEEAB := options["acme_eab"]
|
||||||
globalPreferredChains := options["preferred_chains"]
|
globalPreferredChains := options["preferred_chains"]
|
||||||
hasGlobalACMEDefaults := globalEmail != nil || globalACMECA != nil || globalACMECARoot != nil || globalACMEDNS || globalACMEEAB != nil || globalPreferredChains != nil
|
hasGlobalACMEDefaults := globalEmail != nil || globalACMECA != nil || globalACMECARoot != nil ||
|
||||||
if hasGlobalACMEDefaults {
|
globalACMEDNS || globalACMEEAB != nil || globalPreferredChains != nil
|
||||||
for i := range tlsApp.Automation.Policies {
|
for i := range tlsApp.Automation.Policies {
|
||||||
|
if hasGlobalACMEDefaults {
|
||||||
ap := tlsApp.Automation.Policies[i]
|
ap := tlsApp.Automation.Policies[i]
|
||||||
if len(ap.Issuers) == 0 && automationPolicyHasAllPublicNames(ap) {
|
if len(ap.Issuers) == 0 {
|
||||||
|
// if a specific endpoint is configured, can't use multiple default issuers
|
||||||
|
if globalACMECA != nil {
|
||||||
|
ap.Issuers = []certmagic.Issuer{new(caddytls.ACMEIssuer)}
|
||||||
|
} else if automationPolicyHasAllPublicNames(ap) {
|
||||||
// for public names, create default issuers which will later be filled in with configured global defaults
|
// for public names, create default issuers which will later be filled in with configured global defaults
|
||||||
// (internal names will implicitly use the internal issuer at auto-https time)
|
// (internal names will implicitly use the internal issuer at auto-https time)
|
||||||
emailStr, _ := globalEmail.(string)
|
emailStr, _ := globalEmail.(string)
|
||||||
ap.Issuers = caddytls.DefaultIssuers(emailStr)
|
ap.Issuers = caddytls.DefaultIssuers(emailStr)
|
||||||
|
|
||||||
// if a specific endpoint is configured, can't use multiple default issuers
|
|
||||||
if globalACMECA != nil {
|
|
||||||
ap.Issuers = []certmagic.Issuer{new(caddytls.ACMEIssuer)}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,5 +103,5 @@ func TestIntermediateLifetimeLessThanRoot(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`, "json", "intermediate certificate lifetime must be less than root certificate lifetime (86400h0m0s)")
|
`, "json", "intermediate certificate lifetime must be less than actual root certificate lifetime (86400h0m0s)")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -404,8 +404,12 @@ func (ap *AutomationPolicy) isWildcardOrDefault() bool {
|
|||||||
// DefaultIssuers returns empty Issuers (not provisioned) to be used as defaults.
|
// DefaultIssuers returns empty Issuers (not provisioned) to be used as defaults.
|
||||||
// This function is experimental and has no compatibility promises.
|
// This function is experimental and has no compatibility promises.
|
||||||
func DefaultIssuers(userEmail string) []certmagic.Issuer {
|
func DefaultIssuers(userEmail string) []certmagic.Issuer {
|
||||||
issuers := []certmagic.Issuer{new(ACMEIssuer)}
|
issuers := []certmagic.Issuer{
|
||||||
if strings.TrimSpace(userEmail) != "" {
|
&ACMEIssuer{
|
||||||
|
Email: userEmail,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if strings.TrimSpace(userEmail) != "" { // ZeroSSL requires an email address
|
||||||
issuers = append(issuers, &ACMEIssuer{
|
issuers = append(issuers, &ACMEIssuer{
|
||||||
CA: certmagic.ZeroSSLProductionCA,
|
CA: certmagic.ZeroSSLProductionCA,
|
||||||
Email: userEmail,
|
Email: userEmail,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user