Skip to content

Commit ef7f15f

Browse files
httpcaddyfile: Add auto_https ignore_loaded_certs (#4077)
1 parent 6e0e3e1 commit ef7f15f

File tree

4 files changed

+43
-6
lines changed

4 files changed

+43
-6
lines changed

caddyconfig/httpcaddyfile/builtins.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ func parseTLS(h Helper) ([]ConfigValue, error) {
126126
// must load each cert only once; otherwise, they each get a
127127
// different tag... since a cert loaded twice has the same
128128
// 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)
133133
//
134134
// tlsCertTags maps certificate filenames to their tag.
135135
// This is used to remember which tag is used for each

caddyconfig/httpcaddyfile/httptype.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,9 @@ func (st *ServerType) serversFromPairings(
451451
if autoHTTPS == "disable_redirects" {
452452
srv.AutoHTTPS.DisableRedir = true
453453
}
454+
if autoHTTPS == "ignore_loaded_certs" {
455+
srv.AutoHTTPS.IgnoreLoadedCerts = true
456+
}
454457
}
455458

456459
// sort server blocks by their keys; this is important because

caddyconfig/httpcaddyfile/options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,8 @@ func parseOptAutoHTTPS(d *caddyfile.Dispenser, _ interface{}) (interface{}, erro
379379
if d.Next() {
380380
return "", d.ArgErr()
381381
}
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'")
384384
}
385385
return val, nil
386386
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

0 commit comments

Comments
 (0)