summaryrefslogtreecommitdiff
path: root/caddyconfig/httpcaddyfile
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2022-01-18 14:18:31 -0500
committerGitHub <noreply@github.com>2022-01-18 12:18:31 -0700
commit5a0715689444537cf2c41e3362468b97f31493b6 (patch)
tree660b57d688f4ad6b7947aa06eb21fc7d7ca67ea7 /caddyconfig/httpcaddyfile
parentbcb7a19cd3fbc680a017bc2f5aafa71ff77e87e3 (diff)
httpcaddyfile: Add pki app `root` and `intermediate` cert/key config (#4514)
Diffstat (limited to 'caddyconfig/httpcaddyfile')
-rw-r--r--caddyconfig/httpcaddyfile/pkiapp.go68
1 files changed, 68 insertions, 0 deletions
diff --git a/caddyconfig/httpcaddyfile/pkiapp.go b/caddyconfig/httpcaddyfile/pkiapp.go
index b1aac75..9feb433 100644
--- a/caddyconfig/httpcaddyfile/pkiapp.go
+++ b/caddyconfig/httpcaddyfile/pkiapp.go
@@ -31,6 +31,16 @@ func init() {
// name <name>
// root_cn <name>
// intermediate_cn <name>
+// root {
+// cert <path>
+// key <path>
+// format <format>
+// }
+// intermediate {
+// cert <path>
+// key <path>
+// format <format>
+// }
// }
// }
//
@@ -74,6 +84,64 @@ func parsePKIApp(d *caddyfile.Dispenser, existingVal interface{}) (interface{},
}
pkiCa.IntermediateCommonName = d.Val()
+ case "root":
+ if pkiCa.Root == nil {
+ pkiCa.Root = new(caddypki.KeyPair)
+ }
+ for nesting := d.Nesting(); d.NextBlock(nesting); {
+ switch d.Val() {
+ case "cert":
+ if !d.NextArg() {
+ return nil, d.ArgErr()
+ }
+ pkiCa.Root.Certificate = d.Val()
+
+ case "key":
+ if !d.NextArg() {
+ return nil, d.ArgErr()
+ }
+ pkiCa.Root.PrivateKey = d.Val()
+
+ case "format":
+ if !d.NextArg() {
+ return nil, d.ArgErr()
+ }
+ pkiCa.Root.Format = d.Val()
+
+ default:
+ return nil, d.Errf("unrecognized pki ca root option '%s'", d.Val())
+ }
+ }
+
+ case "intermediate":
+ if pkiCa.Intermediate == nil {
+ pkiCa.Intermediate = new(caddypki.KeyPair)
+ }
+ for nesting := d.Nesting(); d.NextBlock(nesting); {
+ switch d.Val() {
+ case "cert":
+ if !d.NextArg() {
+ return nil, d.ArgErr()
+ }
+ pkiCa.Intermediate.Certificate = d.Val()
+
+ case "key":
+ if !d.NextArg() {
+ return nil, d.ArgErr()
+ }
+ pkiCa.Intermediate.PrivateKey = d.Val()
+
+ case "format":
+ if !d.NextArg() {
+ return nil, d.ArgErr()
+ }
+ pkiCa.Intermediate.Format = d.Val()
+
+ default:
+ return nil, d.Errf("unrecognized pki ca intermediate option '%s'", d.Val())
+ }
+ }
+
default:
return nil, d.Errf("unrecognized pki ca option '%s'", d.Val())
}