caddy/caddyconfig/caddyfile
Matthew Holt 6ca5828221
caddytls: Refactor certificate selection policies (close #1575)
Certificate selection used to be a module, but this seems unnecessary,
especially since the built-in CustomSelectionPolicy allows quite complex
selection logic on a number of fields in certs. If we need to extend
that logic, we can, but I don't think there are SO many possibilities
that we need modules.

This update also allows certificate selection to choose between multiple
matching certs based on client compatibility and makes a number of other
improvements in the default cert selection logic, both here and in the
latest CertMagic.

The hardest part of this was the conn policy consolidation logic
(Caddyfile only, of course). We have to merge connection policies that
we can easily combine, because if two certs are manually loaded in a
Caddyfile site block, that produces two connection policies, and each
cert is tagged with a different tag, meaning only the first would ever
be selected. So given the same matchers, we can merge the two, but this
required improving the Tag selection logic to support multiple tags to
choose from, hence "tags" changed to "any_tag" or "all_tags" (but we
use any_tag in our Caddyfile logic).

Combining conn policies with conflicting settings is impossible, so
that should return an error if two policies with the exact same matchers
have non-empty settings that are not the same (the one exception being
any_tag which we can merge because the logic for them is to OR them).

It was a bit complicated. It seems to work in numerous tests I've
conducted, but we'll see how it pans out in the release candidates.
2020-04-01 20:49:35 -06:00
..
testdata Implement config adapters and beginning of Caddyfile adapter 2019-08-09 12:05:47 -06:00
adapter.go caddytls: Refactor certificate selection policies (close #1575) 2020-04-01 20:49:35 -06:00
dispenser.go caddyfile: Refactor; NewFromNextSegment(); fix repeated matchers 2020-02-14 11:01:09 -07:00
dispenser_test.go caddyfile: Export NewTestDispenser() (close #2930) 2020-04-01 16:34:54 -06:00
formatter.go caddyfile: Minor fixes to the formatter 2020-03-29 13:53:00 -06:00
formatter_test.go caddyfile: Minor fixes to the formatter 2020-03-29 13:53:00 -06:00
lexer.go v2: Make tests work on Windows (#2782) 2019-10-15 16:05:53 -06:00
lexer_test.go v2: Make tests work on Windows (#2782) 2019-10-15 16:05:53 -06:00
parse.go caddyfile: expand environment variables within caddy files (#3082) 2020-02-26 16:06:34 -07:00
parse_fuzz.go ci: fuzz: switch engine from libfuzzer to native go-fuzz (#3194) 2020-03-26 18:20:34 -06:00
parse_test.go caddyfile: Export NewTestDispenser() (close #2930) 2020-04-01 16:34:54 -06:00