Skip to content

Commit e6f46c8

Browse files
authored
acmeserver: Add sign_with_root for Caddyfile (#6345)
* Added sign_with_root option available in the Caddyfile * Added tests for sign_with_root to validate the adapted JSON config
1 parent f6d2c29 commit e6f46c8

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
pki {
3+
ca internal {
4+
name "Internal"
5+
root_cn "Internal Root Cert"
6+
intermediate_cn "Internal Intermediate Cert"
7+
}
8+
}
9+
}
10+
11+
acme.example.com {
12+
acme_server {
13+
ca internal
14+
sign_with_root
15+
}
16+
}
17+
----------
18+
{
19+
"apps": {
20+
"http": {
21+
"servers": {
22+
"srv0": {
23+
"listen": [
24+
":443"
25+
],
26+
"routes": [
27+
{
28+
"match": [
29+
{
30+
"host": [
31+
"acme.example.com"
32+
]
33+
}
34+
],
35+
"handle": [
36+
{
37+
"handler": "subroute",
38+
"routes": [
39+
{
40+
"handle": [
41+
{
42+
"ca": "internal",
43+
"handler": "acme_server",
44+
"sign_with_root": true
45+
}
46+
]
47+
}
48+
]
49+
}
50+
],
51+
"terminal": true
52+
}
53+
]
54+
}
55+
}
56+
},
57+
"pki": {
58+
"certificate_authorities": {
59+
"internal": {
60+
"name": "Internal",
61+
"root_common_name": "Internal Root Cert",
62+
"intermediate_common_name": "Internal Intermediate Cert"
63+
}
64+
}
65+
}
66+
}
67+
}

modules/caddypki/acmeserver/caddyfile.go

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func init() {
4242
// domains <domains...>
4343
// ip_ranges <addresses...>
4444
// }
45+
// sign_with_root
4546
// }
4647
func parseACMEServer(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error) {
4748
h.Next() // consume directive name
@@ -136,6 +137,11 @@ func parseACMEServer(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error
136137
acmeServer.Policy = &Policy{}
137138
}
138139
acmeServer.Policy.Deny = r
140+
case "sign_with_root":
141+
if h.NextArg() {
142+
return nil, h.ArgErr()
143+
}
144+
acmeServer.SignWithRoot = true
139145
default:
140146
return nil, h.Errf("unrecognized ACME server directive: %s", h.Val())
141147
}

0 commit comments

Comments
 (0)