# Default values
CA="https://acme-v01.api.letsencrypt.org/directory"
+ OLDCA=
CERTDIR=
ACCOUNTDIR=
CHALLENGETYPE="http-01"
# Check BASEDIR and set default variables
[[ -d "${BASEDIR}" ]] || _exiterr "BASEDIR does not exist: ${BASEDIR}"
+ # Create new account directory or symlink to account directory from old CA
CAHASH="$(echo "${CA}" | urlbase64)"
[[ -z "${ACCOUNTDIR}" ]] && ACCOUNTDIR="${BASEDIR}/accounts"
- mkdir -p "${ACCOUNTDIR}/${CAHASH}"
+ if [[ ! -e "${ACCOUNTDIR}/${CAHASH}" ]]; then
+ OLDCAHASH="$(echo "${OLDCA}" | urlbase64)"
+ mkdir -p "${ACCOUNTDIR}"
+ if [[ -n "${OLDCA}" ]] && [[ -e "${ACCOUNTDIR}/${OLDCAHASH}" ]]; then
+ echo "! Reusing account from ${OLDCA}"
+ ln -s "${OLDCAHASH}" "${ACCOUNTDIR}/${CAHASH}"
+ else
+ mkdir "${ACCOUNTDIR}/${CAHASH}"
+ fi
+ fi
+
[[ -f "${ACCOUNTDIR}/${CAHASH}/config" ]] && . "${ACCOUNTDIR}/${CAHASH}/config"
ACCOUNT_KEY="${ACCOUNTDIR}/${CAHASH}/account_key.pem"
ACCOUNT_KEY_JSON="${ACCOUNTDIR}/${CAHASH}/registration_info.json"
# Path to certificate authority (default: https://acme-v01.api.letsencrypt.org/directory)
#CA="https://acme-v01.api.letsencrypt.org/directory"
+# Path to old certificate authority
+# Set this value to your old CA value when upgrading from ACMEv1 to ACMEv2 under a different endpoint.
+# If dehydrated detects an account-key for the old CA it will automatically reuse that key
+# instead of registering a new one.
+# default: <unset>
+#OLDCA=
+
# Which challenge should be used? Currently http-01 and dns-01 are supported
#CHALLENGETYPE="http-01"