Skip to content

Commit

Permalink
acmeserver: Add sign_with_root for Caddyfile (#6345)
Browse files Browse the repository at this point in the history
* Added sign_with_root option available in the Caddyfile

* Added tests for sign_with_root to validate the adapted JSON config
  • Loading branch information
Ranveer777 authored May 28, 2024
1 parent f6d2c29 commit e6f46c8
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
pki {
ca internal {
name "Internal"
root_cn "Internal Root Cert"
intermediate_cn "Internal Intermediate Cert"
}
}
}

acme.example.com {
acme_server {
ca internal
sign_with_root
}
}
----------
{
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":443"
],
"routes": [
{
"match": [
{
"host": [
"acme.example.com"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"ca": "internal",
"handler": "acme_server",
"sign_with_root": true
}
]
}
]
}
],
"terminal": true
}
]
}
}
},
"pki": {
"certificate_authorities": {
"internal": {
"name": "Internal",
"root_common_name": "Internal Root Cert",
"intermediate_common_name": "Internal Intermediate Cert"
}
}
}
}
}
6 changes: 6 additions & 0 deletions modules/caddypki/acmeserver/caddyfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func init() {
// domains <domains...>
// ip_ranges <addresses...>
// }
// sign_with_root
// }
func parseACMEServer(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error) {
h.Next() // consume directive name
Expand Down Expand Up @@ -136,6 +137,11 @@ func parseACMEServer(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error
acmeServer.Policy = &Policy{}
}
acmeServer.Policy.Deny = r
case "sign_with_root":
if h.NextArg() {
return nil, h.ArgErr()
}
acmeServer.SignWithRoot = true
default:
return nil, h.Errf("unrecognized ACME server directive: %s", h.Val())
}
Expand Down

0 comments on commit e6f46c8

Please sign in to comment.