Skip to content

Instantly share code, notes, and snippets.

@towo
Created December 11, 2017 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save towo/52b4116ce27127a5e40546cbf571d7a5 to your computer and use it in GitHub Desktop.
Save towo/52b4116ce27127a5e40546cbf571d7a5 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
EVENT_NAME="$1"
[ "$EVENT_NAME" = "live-updated" ] || exit 42
if [ ! -e "${ACME_STATE_DIR}" ]; then
exit 42
fi
umask 0027
mkdir -p "${ACME_STATE_DIR}/pkcs12"
while read name; do
certdir="${ACME_STATE_DIR}/live/${name}"
p12target="${ACME_STATE_DIR}/pkcs12/${name}.p12"
if [ -z "${name}" -o ! -e "${certdir}" ]; then
continue;
fi
if [ -e "${p12target}" ]; then
rm $p12target
fi
if [ -e "${p12target}-password" ]; then
rm "${p12target}-password"
fi
openssl pkcs12 -export \
-out "${p12target}" \
-in "${certdir}/cert" \
-inkey "${certdir}/privkey" \
-chain \
-CAfile "${certdir}/chain" \
-password pass:
# Some applications are dumb and don't work when not using a password for the certificate.
openssl pkcs12 -export \
-out "${p12target}-password" \
-in "${certdir}/cert" \
-inkey "${certdir}/privkey" \
-chain \
-CAfile "${certdir}/chain" \
-password pass:yourapplicationisbadandyoushouldfeelbad
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment