From c2b91dbd65173d256e6fa4ddd3fec6ed2f6c87ef Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 7 Jan 2021 11:01:58 -0700 Subject: httpcaddyfile: Support repeated use of cert_issuer global option This changes the signature of UnmarshalGlobalFunc but this is probably OK since it's only used by this repo as far as we know. We need this change in order to "remember" the previous value in case a global option appears more than once, which is now a possibility with the cert_issuer option since Caddy now supports multiple issuers in the order defined by the user. Bonus: the issuer subdirective of tls now supports one-liner for "acme" when all you need to set is the directory: issuer acme --- modules/caddytls/acmeissuer.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'modules/caddytls') diff --git a/modules/caddytls/acmeissuer.go b/modules/caddytls/acmeissuer.go index 43e758f..64725c9 100644 --- a/modules/caddytls/acmeissuer.go +++ b/modules/caddytls/acmeissuer.go @@ -233,7 +233,7 @@ func (iss *ACMEIssuer) GetACMEIssuer() *ACMEIssuer { return iss } // UnmarshalCaddyfile deserializes Caddyfile tokens into iss. // -// ... acme { +// ... acme [] { // dir // test_dir // email @@ -250,9 +250,18 @@ func (iss *ACMEIssuer) GetACMEIssuer() *ACMEIssuer { return iss } // func (iss *ACMEIssuer) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { for d.Next() { + if d.NextArg() { + iss.CA = d.Val() + if d.NextArg() { + return d.ArgErr() + } + } for nesting := d.Nesting(); d.NextBlock(nesting); { switch d.Val() { case "dir": + if iss.CA != "" { + return d.Errf("directory is already specified: %s", iss.CA) + } if !d.AllArgs(&iss.CA) { return d.ArgErr() } -- cgit v1.2.3