Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 12, 12:00 UTC
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
Ranveer Avhad committed
May 28, 2024 at 05:36 UTC
e6f46c8d78b77d0aefe50750dfd6f6a18ba138e5
2 files changed
+73
caddytest/integration/caddyfile_adapt/acme_server_sign_with_root.caddyfiletest
new
+67
@@ -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
@@ -42,6 +42,7 @@ func init() {
42
// domains <domains...>
43
// ip_ranges <addresses...>
44
// }
45
+// sign_with_root
46
// }
47
func parseACMEServer(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error) {
48
h.Next() // consume directive name
@@ -136,6 +137,11 @@ func parseACMEServer(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error
137
acmeServer.Policy = &Policy{}
138
}
139
acmeServer.Policy.Deny = r
140
+ case "sign_with_root":
141
+ if h.NextArg() {
142
+ return nil, h.ArgErr()
143
+ }
144
+ acmeServer.SignWithRoot = true
145
default:
146
return nil, h.Errf("unrecognized ACME server directive: %s", h.Val())
147
}