mirror of
https://github.com/caddyserver/caddy.git
synced 2025-08-30 23:02:33 -04:00
caddytls: fix regression in external certificate manager support (#7179)
revert changes to automation.go from e276994174983dbb190d4bb9acaab157ef14373b
This commit is contained in:
parent
09b53a753c
commit
b898873b90
@ -173,6 +173,9 @@ type AutomationPolicy struct {
|
||||
subjects []string
|
||||
magic *certmagic.Config
|
||||
storage certmagic.Storage
|
||||
|
||||
// Whether this policy had explicit managers configured directly on it.
|
||||
hadExplicitManagers bool
|
||||
}
|
||||
|
||||
// Provision sets up ap and builds its underlying CertMagic config.
|
||||
@ -209,9 +212,8 @@ func (ap *AutomationPolicy) Provision(tlsApp *TLS) error {
|
||||
// store them on the policy before putting it on the config
|
||||
|
||||
// load and provision any cert manager modules
|
||||
var hadExplicitManagers bool
|
||||
if ap.ManagersRaw != nil {
|
||||
hadExplicitManagers = true
|
||||
ap.hadExplicitManagers = true
|
||||
vals, err := tlsApp.ctx.LoadModule(ap, "ManagersRaw")
|
||||
if err != nil {
|
||||
return fmt.Errorf("loading external certificate manager modules: %v", err)
|
||||
@ -271,9 +273,9 @@ func (ap *AutomationPolicy) Provision(tlsApp *TLS) error {
|
||||
// prevent issuance from Issuers (when Managers don't provide a certificate) if there's no
|
||||
// permission module configured
|
||||
noProtections := ap.isWildcardOrDefault() && !ap.onlyInternalIssuer() && (tlsApp.Automation == nil || tlsApp.Automation.OnDemand == nil || tlsApp.Automation.OnDemand.permission == nil)
|
||||
failClosed := noProtections && !hadExplicitManagers // don't allow on-demand issuance (other than implicit managers) if no managers have been explicitly configured
|
||||
failClosed := noProtections && !ap.hadExplicitManagers // don't allow on-demand issuance (other than implicit managers) if no managers have been explicitly configured
|
||||
if noProtections {
|
||||
if !hadExplicitManagers {
|
||||
if !ap.hadExplicitManagers {
|
||||
// no managers, no explicitly-configured permission module, this is a config error
|
||||
return fmt.Errorf("on-demand TLS cannot be enabled without a permission module to prevent abuse; please refer to documentation for details")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user