caddy
caddy copied to clipboard
Please allow custom CA naming from PKI configuration via Caddyfile
It would be >really< useful to be able to configure custom root CA naming (subject dn string) via the Caddyfile.
Today we have to do something like this in our setup scripts to handle this:
CA_CN_ID=$(cat /sys/class/net/eth0/address | sha1sum | awk '{print $1}')
curl -X POST \
--url http://localhost:2019/config/apps/pki \
-H 'Content-Type: application/json' \
--data "{
\"certificate_authorities\": {
\"local\":{
\"install_trust\": true,
\"root_common_name\": \"Custom Local Root CA - $CA_CN_ID\",
\"intermediate_common_name\": \"Custom Intermediate CA\",
\"name\": \"Custom CA\"
}
}
}"
It would be far easier to use SED on our default Caddyfile that we use, that we bring in via API ahead of that API config with:
HEADERS=(-H 'Content-Type: application/json')
OPTIONS=(-X POST)
URL="localhost:2019/load"
CONF="$(caddy adapt --config /home/pi/elite-pi/elite-caddy/Caddyfile)"
curl "${OPTIONS[@]}" "${URL}" "${HEADERS[@]}" --data "${CONF}"
Feel free to try it out! https://github.com/caddyserver/caddy/pull/4450
@tgelite Does the proposed PR work for your needs? I would like its utility to be verified before merging.