@marcel91200 / caddy Mirror · read-only / commits / 653a0d3f
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 14, 05:15 UTC

httpcaddyfile: Fix automation policies

Fixes a bug introduced in #3862

Matthew Holt committed Feb 8, 2021 at 11:06 UTC 653a0d3f6bd7b66197abd1e00e366164876a9f2b
2 files changed +91 -1
caddyconfig/httpcaddyfile/tlsapp.go
+2 -1
@@ -125,11 +125,12 @@ func (st ServerType) buildTLSApp(
125 if issuerVals, ok := sblock.pile["tls.cert_issuer"]; ok {
126 var issuers []certmagic.Issuer
127 for _, issuerVal := range issuerVals {
128 - ap.Issuers = append(ap.Issuers, issuerVal.Value.(certmagic.Issuer))
128 + issuers = append(issuers, issuerVal.Value.(certmagic.Issuer))
129 }
130 if ap == catchAllAP && !reflect.DeepEqual(ap.Issuers, issuers) {
131 return nil, warnings, fmt.Errorf("automation policy from site block is also default/catch-all policy because of key without hostname, and the two are in conflict: %#v != %#v", ap.Issuers, issuers)
132 }
133 + ap.Issuers = issuers
134 }
135
136 // custom bind host
caddytest/integration/caddyfile_adapt/tls_automation_policies_3.txt new
+89
@@ -0,0 +1,89 @@
1 +# https://caddy.community/t/caddyfile-having-individual-sites-differ-from-global-options/11297
2 +{
3 + local_certs
4 +}
5 +
6 +a.example.com {
7 + tls internal
8 +}
9 +
10 +b.example.com {
11 + tls abc@example.com
12 +}
13 +
14 +c.example.com {
15 +}
16 +----------
17 +{
18 + "apps": {
19 + "http": {
20 + "servers": {
21 + "srv0": {
22 + "listen": [
23 + ":443"
24 + ],
25 + "routes": [
26 + {
27 + "match": [
28 + {
29 + "host": [
30 + "a.example.com"
31 + ]
32 + }
33 + ],
34 + "terminal": true
35 + },
36 + {
37 + "match": [
38 + {
39 + "host": [
40 + "b.example.com"
41 + ]
42 + }
43 + ],
44 + "terminal": true
45 + },
46 + {
47 + "match": [
48 + {
49 + "host": [
50 + "c.example.com"
51 + ]
52 + }
53 + ],
54 + "terminal": true
55 + }
56 + ]
57 + }
58 + }
59 + },
60 + "tls": {
61 + "automation": {
62 + "policies": [
63 + {
64 + "subjects": [
65 + "b.example.com"
66 + ],
67 + "issuers": [
68 + {
69 + "email": "abc@example.com",
70 + "module": "acme"
71 + },
72 + {
73 + "email": "abc@example.com",
74 + "module": "zerossl"
75 + }
76 + ]
77 + },
78 + {
79 + "issuers": [
80 + {
81 + "module": "internal"
82 + }
83 + ]
84 + }
85 + ]
86 + }
87 + }
88 + }
89 +}
\ No newline at end of file