@marcel91200 / caddy Mirror · read-only / commits / a79b4055
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 13, 23:00 UTC

caddytls: Add internal Caddyfile `lifetime`, `sign_with_root` opts (#4513)

Francis Lavoie committed Jan 18, 2022 at 14:19 UTC a79b4055e56dc4e2f2caaae9aea555d1be471948
2 files changed +74 -1
caddytest/integration/caddyfile_adapt/tls_internal_options.txt new
+54
@@ -0,0 +1,54 @@
1 +a.example.com {
2 + tls {
3 + issuer internal {
4 + ca foo
5 + lifetime 24h
6 + sign_with_root
7 + }
8 + }
9 +}
10 +----------
11 +{
12 + "apps": {
13 + "http": {
14 + "servers": {
15 + "srv0": {
16 + "listen": [
17 + ":443"
18 + ],
19 + "routes": [
20 + {
21 + "match": [
22 + {
23 + "host": [
24 + "a.example.com"
25 + ]
26 + }
27 + ],
28 + "terminal": true
29 + }
30 + ]
31 + }
32 + }
33 + },
34 + "tls": {
35 + "automation": {
36 + "policies": [
37 + {
38 + "subjects": [
39 + "a.example.com"
40 + ],
41 + "issuers": [
42 + {
43 + "ca": "foo",
44 + "lifetime": 86400000000000,
45 + "module": "internal",
46 + "sign_with_root": true
47 + }
48 + ]
49 + }
50 + ]
51 + }
52 + }
53 + }
54 +}
\ No newline at end of file
modules/caddytls/internalissuer.go
+20 -1
@@ -149,7 +149,9 @@ func (iss InternalIssuer) Issue(ctx context.Context, csr *x509.CertificateReques
149 // UnmarshalCaddyfile deserializes Caddyfile tokens into iss.
150 //
151 // ... internal {
152 -// ca <name>
152 +// ca <name>
153 +// lifetime <duration>
154 +// sign_with_root
155 // }
156 //
157 func (iss *InternalIssuer) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
@@ -160,6 +162,23 @@ func (iss *InternalIssuer) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
162 if !d.AllArgs(&iss.CA) {
163 return d.ArgErr()
164 }
165 +
166 + case "lifetime":
167 + if !d.NextArg() {
168 + return d.ArgErr()
169 + }
170 + dur, err := caddy.ParseDuration(d.Val())
171 + if err != nil {
172 + return err
173 + }
174 + iss.Lifetime = caddy.Duration(dur)
175 +
176 + case "sign_with_root":
177 + if d.NextArg() {
178 + return d.ArgErr()
179 + }
180 + iss.SignWithRoot = true
181 +
182 }
183 }
184 }