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: Add `auto_https ignore_loaded_certs` (#4077)
Francis Lavoie committed
May 2, 2021 at 14:11 UTC
ef7f15f3a42474319e2db0dff6720d91c153f0bf
4 files changed
+43
-6
caddyconfig/httpcaddyfile/builtins.go
+4
-4
@@ -126,10 +126,10 @@ func parseTLS(h Helper) ([]ConfigValue, error) {
126
// must load each cert only once; otherwise, they each get a
127
// different tag... since a cert loaded twice has the same
128
// bytes, it will overwrite the first one in the cache, and
129
- // only the last cert (and its tag) will survive, so a any conn
130
- // policy that is looking for any tag but the last one to be
131
- // loaded won't find it, and TLS handshakes will fail (see end)
132
- // of issue #3004)
129
+ // only the last cert (and its tag) will survive, so any conn
130
+ // policy that is looking for any tag other than the last one
131
+ // to be loaded won't find it, and TLS handshakes will fail
132
+ // (see end of issue #3004)
133
//
134
// tlsCertTags maps certificate filenames to their tag.
135
// This is used to remember which tag is used for each
caddyconfig/httpcaddyfile/httptype.go
+3
@@ -451,6 +451,9 @@ func (st *ServerType) serversFromPairings(
451
if autoHTTPS == "disable_redirects" {
452
srv.AutoHTTPS.DisableRedir = true
453
}
454
+ if autoHTTPS == "ignore_loaded_certs" {
455
+ srv.AutoHTTPS.IgnoreLoadedCerts = true
456
+ }
457
}
458
459
// sort server blocks by their keys; this is important because
caddyconfig/httpcaddyfile/options.go
+2
-2
@@ -379,8 +379,8 @@ func parseOptAutoHTTPS(d *caddyfile.Dispenser, _ interface{}) (interface{}, erro
379
if d.Next() {
380
return "", d.ArgErr()
381
}
382
- if val != "off" && val != "disable_redirects" {
383
- return "", d.Errf("auto_https must be either 'off' or 'disable_redirects'")
382
+ if val != "off" && val != "disable_redirects" && val != "ignore_loaded_certs" {
383
+ return "", d.Errf("auto_https must be one of 'off', 'disable_redirects' or 'ignore_loaded_certs'")
384
}
385
return val, nil
386
}
caddytest/integration/caddyfile_adapt/auto_https_ignore_loaded_certs.txt
new
+34
@@ -0,0 +1,34 @@
1
+{
2
+ auto_https ignore_loaded_certs
3
+}
4
+
5
+localhost
6
+----------
7
+{
8
+ "apps": {
9
+ "http": {
10
+ "servers": {
11
+ "srv0": {
12
+ "listen": [
13
+ ":443"
14
+ ],
15
+ "routes": [
16
+ {
17
+ "match": [
18
+ {
19
+ "host": [
20
+ "localhost"
21
+ ]
22
+ }
23
+ ],
24
+ "terminal": true
25
+ }
26
+ ],
27
+ "automatic_https": {
28
+ "ignore_loaded_certificates": true
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+}
\ No newline at end of file