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
tls: Add acme_ca_root and tls/ca_root to caddyfile (#3040)
Mark Sargent committed
Feb 13, 2020 at 09:07 UTC
eb80165583776d878256359f1635ffa9a17f0171
3 files changed
+29
-1
caddyconfig/httpcaddyfile/builtins.go
+10
@@ -116,6 +116,9 @@ func parseTLS(h Helper) ([]ConfigValue, error) {
116
if acmeCA := h.Option("acme_ca"); acmeCA != nil {
117
mgr.CA = acmeCA.(string)
118
}
119
+ if caPemFile := h.Option("acme_ca_root"); caPemFile != nil {
120
+ mgr.TrustedRootsPEMFiles = append(mgr.TrustedRootsPEMFiles, caPemFile.(string))
121
+ }
122
123
for h.Next() {
124
// file certificate loader
@@ -232,6 +235,13 @@ func parseTLS(h Helper) ([]ConfigValue, error) {
235
return nil, h.Errf("getting DNS provider module named '%s': %v", provName, err)
236
}
237
mgr.Challenges.DNSRaw = caddyconfig.JSONModuleObject(dnsProvModule.New(), "provider", provName, h.warnings)
238
+
239
+ case "ca_root":
240
+ arg := h.RemainingArgs()
241
+ if len(arg) != 1 {
242
+ return nil, h.ArgErr()
243
+ }
244
+ mgr.TrustedRootsPEMFiles = append(mgr.TrustedRootsPEMFiles, arg[0])
245
246
default:
247
return nil, h.Errf("unknown subdirective: %s", h.Val())
caddyconfig/httpcaddyfile/httptype.go
+1
-1
@@ -71,7 +71,7 @@ func (st ServerType) Setup(originalServerBlocks []caddyfile.ServerBlock,
71
val, err = parseOptExperimentalHTTP3(disp)
72
case "storage":
73
val, err = parseOptStorage(disp)
74
- case "acme_ca", "acme_dns":
74
+ case "acme_ca", "acme_dns", "acme_ca_root":
75
val, err = parseOptACME(disp)
76
case "email":
77
val, err = parseOptEmail(disp)
caddyconfig/httpcaddyfile/parser_test.go
+18
@@ -45,6 +45,24 @@ func TestParse(t *testing.T) {
45
expectWarn: false,
46
expectError: true,
47
},
48
+ {
49
+ input: `
50
+ {
51
+ email test@anon.com
52
+ acme_ca https://ca.custom
53
+ acme_ca_root /root/certs/ca.crt
54
+ }
55
+
56
+ https://caddy {
57
+ tls {
58
+ ca https://ca.custom
59
+ ca_root /root/certs/ca.crt
60
+ }
61
+ }
62
+ `,
63
+ expectWarn: false,
64
+ expectError: false,
65
+ },
66
} {
67
68
adapter := caddyfile.Adapter{