httpcaddyfile, caddytls: Multiple edge case fixes; add tests

- Create two default automation policies; if the TLS app is used in
  isolation with the 'automate' certificate loader, it will now use
  an internal issuer for internal-only names, and an ACME issuer for
  all other names by default.
- If the HTTP Caddyfile adds an 'automate' loader, it now also adds an
  automation policy for any names in that loader that do not qualify
  for public certificates so that they will be issued internally. (It
  might be nice if this wasn't necessary, but the alternative is to
  either make auto-HTTPS logic way more complex by scanning the names in
  the 'automate' loader, or to have an automation policy without an
  issuer switch between default issuer based on the name being issued
  a certificate - I think I like the latter option better, right now we
  do something kind of like that but at a level above each individual
  automation policies, we do that switch only when no automation
  policies match, rather than when a policy without an issuer does
  match.)
- Set the default LoggerName rather than a LoggerNames with an empty
  host value, which is now taken literally rather than as a catch-all.
- hostsFromKeys, the function that gets a list of hosts from server
  block keys, no longer returns an empty string in its resulting slice,
  ever.
This commit is contained in:
Matthew Holt 2020-04-08 14:46:44 -06:00
parent 0fe98038b6
commit 28fdf64dc5
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
6 changed files with 186 additions and 39 deletions

View file

@ -378,7 +378,7 @@ func (st *ServerType) serversFromPairings(
return nil, fmt.Errorf("server block %v: compiling matcher sets: %v", sblock.block.Keys, err)
}
hosts := sblock.hostsFromKeys(false, false)
hosts := sblock.hostsFromKeys(false)
// tls: connection policies
if cpVals, ok := sblock.pile["tls.connection_policy"]; ok {
@ -450,9 +450,13 @@ func (st *ServerType) serversFromPairings(
LoggerNames: make(map[string]string),
}
}
for _, h := range sblock.hostsFromKeys(true, true) {
if ncl.name != "" {
srv.Logs.LoggerNames[h] = ncl.name
if sblock.hasHostCatchAllKey() {
srv.Logs.LoggerName = ncl.name
} else {
for _, h := range sblock.hostsFromKeys(true) {
if ncl.name != "" {
srv.Logs.LoggerNames[h] = ncl.name
}
}
}
}