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 policy consolidation again (fix #4161)
Also fix a previous test that asserted incorrect behavior.
Matthew Holt committed
May 11, 2021 at 15:26 UTC
dbe164d98a58e8b0dbf3fed26e4e9bb6f668a9e2
3 files changed
+124
-13
caddyconfig/httpcaddyfile/tlsapp.go
+4
-1
@@ -510,7 +510,10 @@ outer:
510
// if they're exactly equal in every way, just keep one of them
511
if reflect.DeepEqual(aps[i], aps[j]) {
512
aps = append(aps[:j], aps[j+1:]...)
513
- break
513
+ // must re-evaluate current i against next j; can't skip it!
514
+ // even if i decrements to -1, will be incremented to 0 immediately
515
+ i--
516
+ continue outer
517
}
518
519
// if the policy is the same, we can keep just one, but we have
caddytest/integration/caddyfile_adapt/tls_automation_policies_4.txt
-12
@@ -124,18 +124,6 @@ abc.de {
124
"tls": {
125
"automation": {
126
"policies": [
127
- {
128
- "issuers": [
129
- {
130
- "email": "my.email@example.com",
131
- "module": "acme"
132
- },
133
- {
134
- "email": "my.email@example.com",
135
- "module": "zerossl"
136
- }
137
- ]
138
- },
127
{
128
"issuers": [
129
{
caddytest/integration/caddyfile_adapt/tls_automation_policies_6.txt
new
+120
@@ -0,0 +1,120 @@
1
+# (this Caddyfile is contrived, but based on issue #4161)
2
+
3
+example.com {
4
+ tls {
5
+ ca https://foobar
6
+ }
7
+}
8
+
9
+example.com:8443 {
10
+ tls {
11
+ ca https://foobar
12
+ }
13
+}
14
+
15
+example.com:8444 {
16
+ tls {
17
+ ca https://foobar
18
+ }
19
+}
20
+
21
+example.com:8445 {
22
+ tls {
23
+ ca https://foobar
24
+ }
25
+}
26
+
27
+----------
28
+{
29
+ "apps": {
30
+ "http": {
31
+ "servers": {
32
+ "srv0": {
33
+ "listen": [
34
+ ":443"
35
+ ],
36
+ "routes": [
37
+ {
38
+ "match": [
39
+ {
40
+ "host": [
41
+ "example.com"
42
+ ]
43
+ }
44
+ ],
45
+ "terminal": true
46
+ }
47
+ ]
48
+ },
49
+ "srv1": {
50
+ "listen": [
51
+ ":8443"
52
+ ],
53
+ "routes": [
54
+ {
55
+ "match": [
56
+ {
57
+ "host": [
58
+ "example.com"
59
+ ]
60
+ }
61
+ ],
62
+ "terminal": true
63
+ }
64
+ ]
65
+ },
66
+ "srv2": {
67
+ "listen": [
68
+ ":8444"
69
+ ],
70
+ "routes": [
71
+ {
72
+ "match": [
73
+ {
74
+ "host": [
75
+ "example.com"
76
+ ]
77
+ }
78
+ ],
79
+ "terminal": true
80
+ }
81
+ ]
82
+ },
83
+ "srv3": {
84
+ "listen": [
85
+ ":8445"
86
+ ],
87
+ "routes": [
88
+ {
89
+ "match": [
90
+ {
91
+ "host": [
92
+ "example.com"
93
+ ]
94
+ }
95
+ ],
96
+ "terminal": true
97
+ }
98
+ ]
99
+ }
100
+ }
101
+ },
102
+ "tls": {
103
+ "automation": {
104
+ "policies": [
105
+ {
106
+ "subjects": [
107
+ "example.com"
108
+ ],
109
+ "issuers": [
110
+ {
111
+ "ca": "https://foobar",
112
+ "module": "acme"
113
+ }
114
+ ]
115
+ }
116
+ ]
117
+ }
118
+ }
119
+ }
120
+}
\ No newline at end of file