mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-07-02 03:01:38 +02:00
automatic discovery of remote acme api version
This commit is contained in:
+8
-1
@@ -93,6 +93,7 @@ verify_config() {
|
|||||||
if [[ -n "${IP_VERSION}" ]]; then
|
if [[ -n "${IP_VERSION}" ]]; then
|
||||||
[[ "${IP_VERSION}" = "4" || "${IP_VERSION}" = "6" ]] || _exiterr "Unknown IP version ${IP_VERSION}... cannot continue."
|
[[ "${IP_VERSION}" = "4" || "${IP_VERSION}" = "6" ]] || _exiterr "Unknown IP version ${IP_VERSION}... cannot continue."
|
||||||
fi
|
fi
|
||||||
|
[[ "${API}" == "auto" || "${API}" == "1" || "${API}" == "2" ]] || _exiterr "Unsupported API version defined in config: ${API}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Setup default config values, search for and load configuration files
|
# Setup default config values, search for and load configuration files
|
||||||
@@ -138,7 +139,7 @@ load_config() {
|
|||||||
AUTO_CLEANUP="no"
|
AUTO_CLEANUP="no"
|
||||||
DEHYDRATED_USER=
|
DEHYDRATED_USER=
|
||||||
DEHYDRATED_GROUP=
|
DEHYDRATED_GROUP=
|
||||||
API=1
|
API="auto"
|
||||||
|
|
||||||
if [[ -z "${CONFIG:-}" ]]; then
|
if [[ -z "${CONFIG:-}" ]]; then
|
||||||
echo "#" >&2
|
echo "#" >&2
|
||||||
@@ -263,6 +264,12 @@ init_system() {
|
|||||||
|
|
||||||
# Get CA URLs
|
# Get CA URLs
|
||||||
CA_DIRECTORY="$(http_request get "${CA}")"
|
CA_DIRECTORY="$(http_request get "${CA}")"
|
||||||
|
|
||||||
|
# Automatic discovery of API version
|
||||||
|
if [[ "${API}" = "auto" ]]; then
|
||||||
|
grep -q newOrder <<< "${CA_DIRECTORY}" && API=2 || API=1
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ ${API} -eq 1 ]]; then
|
if [[ ${API} -eq 1 ]]; then
|
||||||
# shellcheck disable=SC2015
|
# shellcheck disable=SC2015
|
||||||
CA_NEW_CERT="$(printf "%s" "${CA_DIRECTORY}" | get_json_string_value new-cert)" &&
|
CA_NEW_CERT="$(printf "%s" "${CA_DIRECTORY}" | get_json_string_value new-cert)" &&
|
||||||
|
|||||||
@@ -111,5 +111,5 @@
|
|||||||
# Automatic cleanup (default: no)
|
# Automatic cleanup (default: no)
|
||||||
#AUTO_CLEANUP="no"
|
#AUTO_CLEANUP="no"
|
||||||
|
|
||||||
# ACME API version (default: 1)
|
# ACME API version (default: auto)
|
||||||
#API=1
|
#API=auto
|
||||||
|
|||||||
Reference in New Issue
Block a user