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
This commit is contained in:
Ranveer Avhad 2024-05-28 05:36:54 +05:30 committed by GitHub
parent f6d2c293e7
commit e6f46c8d78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 73 additions and 0 deletions

View file

@ -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"
}
}
}
}
}

View file

@ -42,6 +42,7 @@ func init() {
// domains <domains...> // domains <domains...>
// ip_ranges <addresses...> // ip_ranges <addresses...>
// } // }
// sign_with_root
// } // }
func parseACMEServer(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error) { func parseACMEServer(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error) {
h.Next() // consume directive name h.Next() // consume directive name
@ -136,6 +137,11 @@ func parseACMEServer(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error
acmeServer.Policy = &Policy{} acmeServer.Policy = &Policy{}
} }
acmeServer.Policy.Deny = r acmeServer.Policy.Deny = r
case "sign_with_root":
if h.NextArg() {
return nil, h.ArgErr()
}
acmeServer.SignWithRoot = true
default: default:
return nil, h.Errf("unrecognized ACME server directive: %s", h.Val()) return nil, h.Errf("unrecognized ACME server directive: %s", h.Val())
} }