You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
httpcaddyfile: Improve detection of indistinguishable TLS automation policies (#5120)
* httpcaddyfile: Skip some logic if auto_https off
* Try removing this check altogether...
* Refine test timeouts slightly, sigh
* caddyhttp: Assume udp for unrecognized network type
Seems like the reasonable thing to do if a plugin registers its own
network type.
* Add comment to document my lack of knowledge
* Clean up and prepare to merge
Add comments to try to explain what happened
// this more correctly implements an error check that was removed
133
+
// below; try it with this config:
134
+
//
135
+
// :443 {
136
+
// bind 127.0.0.1
137
+
// }
138
+
//
139
+
// :443 {
140
+
// bind ::1
141
+
// tls {
142
+
// issuer acme
143
+
// }
144
+
// }
141
145
returnnil, 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)
// first make sure this block is allowed to create an automation policy;
184
-
// doing so is forbidden if it has a key with no host (i.e. ":443")
187
+
// we used to ensure this block is allowed to create an automation policy;
188
+
// doing so was forbidden if it has a key with no host (i.e. ":443")
185
189
// and if there is a different server block that also has a key with no
186
190
// host -- since a key with no host matches any host, we need its
187
191
// associated automation policy to have an empty Subjects list, i.e. no
188
192
// host filter, which is indistinguishable between the two server blocks
189
193
// because automation is not done in the context of a particular server...
190
194
// this is an example of a poor mapping from Caddyfile to JSON but that's
191
-
// the least-leaky abstraction I could figure out
192
-
iflen(sblockHosts) ==0 {
193
-
ifserverBlocksWithTLSHostlessKey>1 {
194
-
// this server block and at least one other has a key with no host,
195
-
// making the two indistinguishable; it is misleading to define such
196
-
// a policy within one server block since it actually will apply to
197
-
// others as well
198
-
returnnil, warnings, fmt.Errorf("cannot make a TLS automation policy from a server block that has a host-less address when there are other TLS-enabled server block addresses lacking a host")
199
-
}
200
-
ifcatchAllAP==nil {
201
-
// this server block has a key with no hosts, but there is not yet
202
-
// a catch-all automation policy (probably because no global options
203
-
// were set), so this one becomes it
204
-
catchAllAP=ap
205
-
}
195
+
// the least-leaky abstraction I could figure out -- however, this check
196
+
// was preventing certain listeners, like those provided by plugins, from
197
+
// being used as desired (see the Tailscale listener plugin), so I removed
198
+
// the check: and I think since I originally wrote the check I added a new
199
+
// check above which *properly* detects this ambiguity without breaking the
200
+
// listener plugin; see the check above with a commented example config
201
+
iflen(sblockHosts) ==0&&catchAllAP==nil {
202
+
// this server block has a key with no hosts, but there is not yet
203
+
// a catch-all automation policy (probably because no global options
204
+
// were set), so this one becomes it
205
+
catchAllAP=ap
206
206
}
207
207
208
208
// associate our new automation policy with this server block's hosts
0 commit comments