@marcel91200 / caddy Mirror · read-only / commits / 4564261d
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 11, 22:15 UTC

httpcaddyfile: Fix `acme_dns` regression (#7199)

Francis Lavoie committed Aug 22, 2025 at 17:09 UTC 4564261d8350f8010b7e001e646e260e9bba5746
3 files changed +93 -15
caddyconfig/httpcaddyfile/tlsapp.go
+16 -15
@@ -564,21 +564,22 @@ func fillInGlobalACMEDefaults(issuer certmagic.Issuer, options map[string]any) e
564 if globalACMECARoot != nil && !slices.Contains(acmeIssuer.TrustedRootsPEMFiles, globalACMECARoot.(string)) {
565 acmeIssuer.TrustedRootsPEMFiles = append(acmeIssuer.TrustedRootsPEMFiles, globalACMECARoot.(string))
566 }
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 - }
574 - acmeIssuer.Challenges = &caddytls.ChallengesConfig{
575 - DNS: new(caddytls.DNSChallengeConfig),
576 - }
577 - } else if globalACMEDNS != nil {
578 - acmeIssuer.Challenges = &caddytls.ChallengesConfig{
579 - DNS: &caddytls.DNSChallengeConfig{
580 - ProviderRaw: caddyconfig.JSONModuleObject(globalACMEDNS, "name", globalACMEDNS.(caddy.Module).CaddyModule().ID.Name(), nil),
581 - },
567 + if globalACMEDNSok {
568 + globalDNS := options["dns"]
569 + if globalDNS != nil {
570 + // If global `dns` is set, do NOT set provider in issuer, just set empty dns config
571 + acmeIssuer.Challenges = &caddytls.ChallengesConfig{
572 + DNS: &caddytls.DNSChallengeConfig{},
573 + }
574 + } else if globalACMEDNS != nil {
575 + // Set a global DNS provider if `acme_dns` is set and `dns` is NOT set
576 + acmeIssuer.Challenges = &caddytls.ChallengesConfig{
577 + DNS: &caddytls.DNSChallengeConfig{
578 + ProviderRaw: caddyconfig.JSONModuleObject(globalACMEDNS, "name", globalACMEDNS.(caddy.Module).CaddyModule().ID.Name(), nil),
579 + },
580 + }
581 + } else {
582 + return fmt.Errorf("acme_dns specified without DNS provider config, but no provider specified with 'dns' global option")
583 }
584 }
585 if globalACMEEAB != nil && acmeIssuer.ExternalAccount == nil {
caddytest/integration/caddyfile_adapt/acme_dns_configured.caddyfiletest new
+68
@@ -0,0 +1,68 @@
1 +{
2 + acme_dns mock foo
3 +}
4 +
5 +example.com {
6 + respond "Hello World"
7 +}
8 +----------
9 +{
10 + "apps": {
11 + "http": {
12 + "servers": {
13 + "srv0": {
14 + "listen": [
15 + ":443"
16 + ],
17 + "routes": [
18 + {
19 + "match": [
20 + {
21 + "host": [
22 + "example.com"
23 + ]
24 + }
25 + ],
26 + "handle": [
27 + {
28 + "handler": "subroute",
29 + "routes": [
30 + {
31 + "handle": [
32 + {
33 + "body": "Hello World",
34 + "handler": "static_response"
35 + }
36 + ]
37 + }
38 + ]
39 + }
40 + ],
41 + "terminal": true
42 + }
43 + ]
44 + }
45 + }
46 + },
47 + "tls": {
48 + "automation": {
49 + "policies": [
50 + {
51 + "issuers": [
52 + {
53 + "challenges": {
54 + "dns": {
55 + "provider": {
56 + "name": "mock"
57 + }
58 + }
59 + },
60 + "module": "acme"
61 + }
62 + ]
63 + }
64 + ]
65 + }
66 + }
67 + }
68 +}
\ No newline at end of file
caddytest/integration/caddyfile_adapt/acme_dns_naked_without_dns.caddyfiletest new
+9
@@ -0,0 +1,9 @@
1 +{
2 + acme_dns
3 +}
4 +
5 +example.com {
6 + respond "Hello World"
7 +}
8 +----------
9 +acme_dns specified without DNS provider config, but no provider specified with 'dns' global option
\ No newline at end of file