dumpcerts.sh: Fix call to "base64" for Alpine
This commit is contained in:
parent
ee70001be3
commit
91ff94ea56
1 changed files with 14 additions and 2 deletions
|
@ -42,6 +42,18 @@ set -o nounset
|
||||||
|
|
||||||
USAGE="$(basename "$0") <path to acme> <destination cert directory>"
|
USAGE="$(basename "$0") <path to acme> <destination cert directory>"
|
||||||
|
|
||||||
|
# Platform variations
|
||||||
|
case "$(uname)" in
|
||||||
|
'Linux')
|
||||||
|
# On Linux, -d should always work. --decode does not work with Alpine's busybox-binary
|
||||||
|
CMD_DECODE_BASE64="base64 -d"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# Max OS-X supports --decode and -D, but --decode may be supported by other platforms as well.
|
||||||
|
CMD_DECODE_BASE64="base64 --decode"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Allow us to exit on a missing jq binary
|
# Allow us to exit on a missing jq binary
|
||||||
exit_jq() {
|
exit_jq() {
|
||||||
echo "
|
echo "
|
||||||
|
@ -149,10 +161,10 @@ for domain in $(jq -r '.DomainsCertificate.Certs[].Certificate.Domain' ${acmefil
|
||||||
echo "Extracting cert bundle for ${domain}"
|
echo "Extracting cert bundle for ${domain}"
|
||||||
cert=$(jq -e -r --arg domain "$domain" '.DomainsCertificate.Certs[].Certificate |
|
cert=$(jq -e -r --arg domain "$domain" '.DomainsCertificate.Certs[].Certificate |
|
||||||
select (.Domain == $domain )| .Certificate' ${acmefile}) || bad_acme
|
select (.Domain == $domain )| .Certificate' ${acmefile}) || bad_acme
|
||||||
echo "${cert}" | base64 --decode > "${cdir}/${domain}.crt"
|
echo "${cert}" | ${CMD_DECODE_BASE64} > "${cdir}/${domain}.crt"
|
||||||
|
|
||||||
echo "Extracting private key for ${domain}"
|
echo "Extracting private key for ${domain}"
|
||||||
key=$(jq -e -r --arg domain "$domain" '.DomainsCertificate.Certs[].Certificate |
|
key=$(jq -e -r --arg domain "$domain" '.DomainsCertificate.Certs[].Certificate |
|
||||||
select (.Domain == $domain )| .PrivateKey' ${acmefile}) || bad_acme
|
select (.Domain == $domain )| .PrivateKey' ${acmefile}) || bad_acme
|
||||||
echo "${key}" | base64 --decode > "${pdir}/${domain}.key"
|
echo "${key}" | ${CMD_DECODE_BASE64} > "${pdir}/${domain}.key"
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue