0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00
caddy/caddyhttp
Matthew Holt fc2ff9155c
tls: Restructure and improve certificate management
- Expose the list of Caddy instances through caddy.Instances()

- Added arbitrary storage to caddy.Instance

- The cache of loaded certificates is no longer global; now scoped
  per-instance, meaning upon reload (like SIGUSR1) the old cert cache
  will be discarded entirely, whereas before, aggressively reloading
  config that added and removed lots of sites would cause unnecessary
  build-up in the cache over time.

- Key certificates in the cache by their SHA-256 hash instead of
  by their names. This means certificates will not be duplicated in
  memory (within each instance), making Caddy much more memory-efficient
  for large-scale deployments with thousands of sites sharing certs.

- Perform name-to-certificate lookups scoped per caddytls.Config instead
  of a single global lookup. This prevents certificates from stepping on
  each other when they overlap in their names.

- Do not allow TLS configurations keyed by the same hostname to be
  different; this now throws an error.

- Updated relevant tests, with a stark awareness that more tests are
  needed.

- Change the NewContext function signature to include an *Instance.

- Strongly recommend (basically require) use of caddytls.NewConfig()
  to create a new *caddytls.Config, to ensure pointers to the instance
  certificate cache are initialized properly.

- Update the TLS-SNI challenge solver (even though TLS-SNI is disabled
  currently on the CA side). Store temporary challenge cert in instance
  cache, but do so directly by the ACME challenge name, not the hash.
  Modified the getCertificate function to check the cache directly for
  a name match if one isn't found otherwise. This will allow any
  caddytls.Config to be able to help solve a TLS-SNI challenge, with one
  extra side-effect that might actually be kind of interesting (and
  useless): clients could send a certificate's hash as the SNI and
  Caddy would be able to serve that certificate for the handshake.

- Do not attempt to match a "default" (random) certificate when SNI
  is present but unrecognized; return no certificate so a TLS alert
  happens instead.

- Store an Instance in the list of instances even while the instance
  is still starting up (this allows access to the cert cache for
  performing renewals at startup, etc). Will be removed from list again
  if instance startup fails.

- Laid groundwork for ACMEv2 and Let's Encrypt wildcard support.

Server type plugins will need to be updated slightly to accommodate
minor adjustments to their API (like passing in an Instance). This
commit includes the changes for the HTTP server.

Certain Caddyfile configurations might error out with this change, if
they configured different TLS settings for the same hostname.

This change trades some complexity for other complexity, but ultimately
this new complexity is more correct and robust than earlier logic.

Fixes #1991
Fixes #1994
Fixes #1303
2018-02-04 00:58:27 -07:00
..
basicauth add basicauth {user} to replacer (#1979) 2018-01-07 14:44:49 +00:00
bind Apply Apache license to all .go source files (closes #1865) 2017-09-22 23:56:58 -06:00
browse Implement per-site index (#1906) 2017-10-29 21:13:10 +00:00
errors Apply Apache license to all .go source files (closes #1865) 2017-09-22 23:56:58 -06:00
expvar Apply Apache license to all .go source files (closes #1865) 2017-09-22 23:56:58 -06:00
extensions Apply Apache license to all .go source files (closes #1865) 2017-09-22 23:56:58 -06:00
fastcgi fastcgi: Add support for SRV upstreams (#1870) 2017-10-03 07:17:54 -06:00
gzip Apply Apache license to all .go source files (closes #1865) 2017-09-22 23:56:58 -06:00
header Apply Apache license to all .go source files (closes #1865) 2017-09-22 23:56:58 -06:00
httpserver tls: Restructure and improve certificate management 2018-02-04 00:58:27 -07:00
index Implement per-site index (#1906) 2017-10-29 21:13:10 +00:00
internalsrv Apply Apache license to all .go source files (closes #1865) 2017-09-22 23:56:58 -06:00
limits Apply Apache license to all .go source files (closes #1865) 2017-09-22 23:56:58 -06:00
log Allow Masking of IP address in Logfile. (#1930) 2017-12-23 10:52:11 +00:00
markdown markdown: only update template when file changed (#1909) 2017-11-04 17:36:59 +00:00
mime Apply Apache license to all .go source files (closes #1865) 2017-09-22 23:56:58 -06:00
pprof Apply Apache license to all .go source files (closes #1865) 2017-09-22 23:56:58 -06:00
proxy proxy: Add SRV support for proxy upstream (#1915) 2017-11-05 23:01:10 -07:00
push Implement per-site index (#1906) 2017-10-29 21:13:10 +00:00
redirect redir: Do not count multiple rules with if statements as duplicates 2017-09-28 11:41:11 -06:00
requestid Implement 'http.on' plugin and replace UUID lib (#1864) 2017-10-01 11:24:50 -06:00
rewrite Apply Apache license to all .go source files (closes #1865) 2017-09-22 23:56:58 -06:00
root Apply Apache license to all .go source files (closes #1865) 2017-09-22 23:56:58 -06:00
staticfiles Implement per-site index (#1906) 2017-10-29 21:13:10 +00:00
status Apply Apache license to all .go source files (closes #1865) 2017-09-22 23:56:58 -06:00
templates Apply Apache license to all .go source files (closes #1865) 2017-09-22 23:56:58 -06:00
timeouts Apply Apache license to all .go source files (closes #1865) 2017-09-22 23:56:58 -06:00
websocket Apply Apache license to all .go source files (closes #1865) 2017-09-22 23:56:58 -06:00
caddyhttp.go Implement 'http.on' plugin and replace UUID lib (#1864) 2017-10-01 11:24:50 -06:00
caddyhttp_test.go Implement 'http.on' plugin and replace UUID lib (#1864) 2017-10-01 11:24:50 -06:00