You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the nginx proxy manager for a lot of projects. I am using (most times) *.example.com certificates.
To have a single point of how and where I generate them, I wrote a small script to exprt cert + private key e.g. for using it in Truenas or similar other systems.
Here the script: export-cert.sh
export-cert.sh and ./letsencrypt are located in the same directory.
You can use export-cert.sh *.example.org - that creates certs-*.example.org.zip
You can also can the script by export-cert.sh *.example.org --. That will generate the zip file to stdout (very usefull in ansible, ssh etc.)
Have fun.
#!/bin/bashif [ -z"$1" ];thenecho"Error: missing domain parameter."exit 1
fi
DOMAIN="$1"
SCRIPT_DIR="$(cd -- "$(dirname "$0")">/dev/null 2>&1;pwd -P )"
CURRENT_CERTS_DIR="${SCRIPT_DIR}/letsencrypt/live"
ZIP_FILE="${SCRIPT_DIR}/certs-${DOMAIN}.zip"if [ "$2"="--" ];then# redirect to stdout
ZIP_FILE="-"fi
TMPFILE="$(mktemp)"trap'rm -rf -- "$TMPFILE"' EXIT
find "${CURRENT_CERTS_DIR}" \
-name "cert.pem" \
-exec sh -c 'openssl x509 -noout -subject -in $0 | sed -s "s|.*= ||" | sed -z "s|\n|, |g" && echo "$0" ' {} \;>"${TMPFILE}"
MATCH=$(cat "${TMPFILE}"| grep -e "^${DOMAIN},"| head -n1)if [ -z"${MATCH}" ];thenecho"Error: domain ${DOMAIN} not found."exit 1
fi
CERT_FILE=$(echo "${MATCH}"| sed -e 's|^.*, ||')
KEY_FILE=$(dirname "${CERT_FILE}")/privkey.pem
zip -qq -j "${ZIP_FILE}""${CERT_FILE}""${KEY_FILE}"
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am using the nginx proxy manager for a lot of projects. I am using (most times) *.example.com certificates.
To have a single point of how and where I generate them, I wrote a small script to exprt cert + private key e.g. for using it in Truenas or similar other systems.
Here the script: export-cert.sh
export-cert.sh and ./letsencrypt are located in the same directory.
You can use
export-cert.sh *.example.org
- that createscerts-*.example.org.zip
You can also can the script by
export-cert.sh *.example.org --
. That will generate the zip file to stdout (very usefull in ansible, ssh etc.)Have fun.
Beta Was this translation helpful? Give feedback.
All reactions