@@ -464,10 +464,10 @@ func (st ServerType) buildTLSApp(
464464 globalEmail := options ["email" ]
465465 globalACMECA := options ["acme_ca" ]
466466 globalACMECARoot := options ["acme_ca_root" ]
467- globalACMEDNS := options ["acme_dns" ]
467+ _ , globalACMEDNS := options ["acme_dns" ] // can be set to nil (to use globally-defined "dns" value instead), but it is still set
468468 globalACMEEAB := options ["acme_eab" ]
469469 globalPreferredChains := options ["preferred_chains" ]
470- hasGlobalACMEDefaults := globalEmail != nil || globalACMECA != nil || globalACMECARoot != nil || globalACMEDNS != nil || globalACMEEAB != nil || globalPreferredChains != nil
470+ hasGlobalACMEDefaults := globalEmail != nil || globalACMECA != nil || globalACMECARoot != nil || globalACMEDNS || globalACMEEAB != nil || globalPreferredChains != nil
471471 if hasGlobalACMEDefaults {
472472 for i := range tlsApp .Automation .Policies {
473473 ap := tlsApp .Automation .Policies [i ]
@@ -549,7 +549,7 @@ func fillInGlobalACMEDefaults(issuer certmagic.Issuer, options map[string]any) e
549549 globalEmail := options ["email" ]
550550 globalACMECA := options ["acme_ca" ]
551551 globalACMECARoot := options ["acme_ca_root" ]
552- globalACMEDNS := options ["acme_dns" ]
552+ globalACMEDNS , globalACMEDNSok := options ["acme_dns" ] // can be set to nil (to use globally-defined "dns" value instead), but it is still set
553553 globalACMEEAB := options ["acme_eab" ]
554554 globalPreferredChains := options ["preferred_chains" ]
555555 globalCertLifetime := options ["cert_lifetime" ]
@@ -564,7 +564,13 @@ func fillInGlobalACMEDefaults(issuer certmagic.Issuer, options map[string]any) e
564564 if globalACMECARoot != nil && ! slices .Contains (acmeIssuer .TrustedRootsPEMFiles , globalACMECARoot .(string )) {
565565 acmeIssuer .TrustedRootsPEMFiles = append (acmeIssuer .TrustedRootsPEMFiles , globalACMECARoot .(string ))
566566 }
567- if globalACMEDNS != nil && (acmeIssuer .Challenges == nil || acmeIssuer .Challenges .DNS == nil ) {
567+ if globalACMEDNSok && (acmeIssuer .Challenges == nil || acmeIssuer .Challenges .DNS == nil ) {
568+ if globalACMEDNS == nil {
569+ globalACMEDNS = options ["dns" ]
570+ if globalACMEDNS == nil {
571+ return fmt .Errorf ("acme_dns specified without DNS provider config, but no provider specified with 'dns' global option" )
572+ }
573+ }
568574 acmeIssuer .Challenges = & caddytls.ChallengesConfig {
569575 DNS : & caddytls.DNSChallengeConfig {
570576 ProviderRaw : caddyconfig .JSONModuleObject (globalACMEDNS , "name" , globalACMEDNS .(caddy.Module ).CaddyModule ().ID .Name (), nil ),
0 commit comments