| 1 | #! /bin/sh |
| 2 | set -e |
| 3 | . "${0%/*}/../config.sh" |
| 4 | . "$home/lib/lib.sh" |
| 5 | |
| 6 | run_as_user "$@" |
| 7 | |
| 8 | ## Pick out the certificate tag. |
| 9 | case $# in 0) fail_usage ;; esac |
| 10 | tag=$1; shift |
| 11 | case $# in 0) ;; *) fail_usage ;; esac |
| 12 | |
| 13 | prepare_tmp $tag |
| 14 | |
| 15 | ## Get started. |
| 16 | cd $home/cert/$tag |
| 17 | openssl req -in req -out $tmp/req.der -outform der |
| 18 | sans=$(openssl req -in req -text -noout | |
| 19 | sed -n ' |
| 20 | x |
| 21 | /^ *X509v3 Subject Alternative Name: $/ { |
| 22 | x |
| 23 | s/ *DNS://g |
| 24 | s/,/ /g |
| 25 | p |
| 26 | x |
| 27 | }') |
| 28 | make_le_conf $sans |
| 29 | |
| 30 | cat "$tmp/le.conf" |