caddy icon indicating copy to clipboard operation
caddy copied to clipboard

Please allow custom CA naming from PKI configuration via Caddyfile

Open tgelite opened this issue 5 years ago • 2 comments

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

tgelite avatar Nov 24 '21 01:11 tgelite

Feel free to try it out! https://github.com/caddyserver/caddy/pull/4450

francislavoie avatar Nov 28 '21 21:11 francislavoie

@tgelite Does the proposed PR work for your needs? I would like its utility to be verified before merging.

mholt avatar Dec 13 '21 20:12 mholt