|
@ -1,6 +1,6 @@ |
|
|
#!/usr/bin/env sh |
|
|
#!/usr/bin/env sh |
|
|
|
|
|
|
|
|
VER=2.7.7 |
|
|
|
|
|
|
|
|
VER=2.7.8 |
|
|
|
|
|
|
|
|
PROJECT_NAME="acme.sh" |
|
|
PROJECT_NAME="acme.sh" |
|
|
|
|
|
|
|
@ -47,6 +47,7 @@ DEFAULT_DNS_SLEEP=120 |
|
|
NO_VALUE="no" |
|
|
NO_VALUE="no" |
|
|
|
|
|
|
|
|
W_TLS="tls" |
|
|
W_TLS="tls" |
|
|
|
|
|
W_DNS="dns" |
|
|
DNS_ALIAS_PREFIX="=" |
|
|
DNS_ALIAS_PREFIX="=" |
|
|
|
|
|
|
|
|
MODE_STATELESS="stateless" |
|
|
MODE_STATELESS="stateless" |
|
@ -2341,7 +2342,7 @@ _initpath() { |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
_debug2 ACME_DIRECTORY "$ACME_DIRECTORY" |
|
|
|
|
|
|
|
|
_debug ACME_DIRECTORY "$ACME_DIRECTORY" |
|
|
_ACME_SERVER_HOST="$(echo "$ACME_DIRECTORY" | cut -d : -f 2 | tr -s / | cut -d / -f 2)" |
|
|
_ACME_SERVER_HOST="$(echo "$ACME_DIRECTORY" | cut -d : -f 2 | tr -s / | cut -d / -f 2)" |
|
|
_debug2 "_ACME_SERVER_HOST" "$_ACME_SERVER_HOST" |
|
|
_debug2 "_ACME_SERVER_HOST" "$_ACME_SERVER_HOST" |
|
|
|
|
|
|
|
@ -2998,6 +2999,8 @@ _on_before_issue() { |
|
|
_chk_pre_hook="$4" |
|
|
_chk_pre_hook="$4" |
|
|
_chk_local_addr="$5" |
|
|
_chk_local_addr="$5" |
|
|
_debug _on_before_issue |
|
|
_debug _on_before_issue |
|
|
|
|
|
_debug _chk_main_domain "$_chk_main_domain" |
|
|
|
|
|
_debug _chk_alt_domains "$_chk_alt_domains" |
|
|
#run pre hook |
|
|
#run pre hook |
|
|
if [ "$_chk_pre_hook" ]; then |
|
|
if [ "$_chk_pre_hook" ]; then |
|
|
_info "Run pre hook:'$_chk_pre_hook'" |
|
|
_info "Run pre hook:'$_chk_pre_hook'" |
|
@ -3018,11 +3021,17 @@ _on_before_issue() { |
|
|
|
|
|
|
|
|
_debug Le_LocalAddress "$_chk_local_addr" |
|
|
_debug Le_LocalAddress "$_chk_local_addr" |
|
|
|
|
|
|
|
|
alldomains=$(echo "$_chk_main_domain,$_chk_alt_domains" | tr ',' ' ') |
|
|
|
|
|
_index=1 |
|
|
_index=1 |
|
|
_currentRoot="" |
|
|
_currentRoot="" |
|
|
_addrIndex=1 |
|
|
_addrIndex=1 |
|
|
for d in $alldomains; do |
|
|
|
|
|
|
|
|
_w_index=1 |
|
|
|
|
|
while true; do |
|
|
|
|
|
d="$(echo "$_chk_main_domain,$_chk_alt_domains," | cut -d , -f "$_w_index")" |
|
|
|
|
|
_w_index="$(_math "$_w_index" + 1)" |
|
|
|
|
|
_debug d "$d" |
|
|
|
|
|
if [ -z "$d" ]; then |
|
|
|
|
|
break |
|
|
|
|
|
fi |
|
|
_debug "Check for domain" "$d" |
|
|
_debug "Check for domain" "$d" |
|
|
_currentRoot="$(_getfield "$_chk_web_roots" $_index)" |
|
|
_currentRoot="$(_getfield "$_chk_web_roots" $_index)" |
|
|
_debug "_currentRoot" "$_currentRoot" |
|
|
_debug "_currentRoot" "$_currentRoot" |
|
@ -3118,7 +3127,7 @@ _on_issue_err() { |
|
|
) |
|
|
) |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
if [ "$IS_RENEW" = "1" ] && _hasfield "$Le_Webroot" "dns"; then |
|
|
|
|
|
|
|
|
if [ "$IS_RENEW" = "1" ] && _hasfield "$Le_Webroot" "$W_DNS"; then |
|
|
_err "$_DNS_MANUAL_ERR" |
|
|
_err "$_DNS_MANUAL_ERR" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
@ -3154,7 +3163,7 @@ _on_issue_success() { |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
if _hasfield "$Le_Webroot" "dns"; then |
|
|
|
|
|
|
|
|
if _hasfield "$Le_Webroot" "$W_DNS"; then |
|
|
_err "$_DNS_MANUAL_WARN" |
|
|
_err "$_DNS_MANUAL_WARN" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
@ -3421,6 +3430,9 @@ issue() { |
|
|
_main_domain=$(echo "$2,$3" | cut -d , -f 1) |
|
|
_main_domain=$(echo "$2,$3" | cut -d , -f 1) |
|
|
_alt_domains=$(echo "$2,$3" | cut -d , -f 2- | sed "s/,${NO_VALUE}$//") |
|
|
_alt_domains=$(echo "$2,$3" | cut -d , -f 2- | sed "s/,${NO_VALUE}$//") |
|
|
fi |
|
|
fi |
|
|
|
|
|
_debug _main_domain "$_main_domain" |
|
|
|
|
|
_debug _alt_domains "$_alt_domains" |
|
|
|
|
|
|
|
|
_key_length="$4" |
|
|
_key_length="$4" |
|
|
_real_cert="$5" |
|
|
_real_cert="$5" |
|
|
_real_key="$6" |
|
|
_real_key="$6" |
|
@ -3551,10 +3563,15 @@ issue() { |
|
|
if [ "$ACME_VERSION" = "2" ]; then |
|
|
if [ "$ACME_VERSION" = "2" ]; then |
|
|
#make new order request |
|
|
#make new order request |
|
|
_identifiers="{\"type\":\"dns\",\"value\":\"$_main_domain\"}" |
|
|
_identifiers="{\"type\":\"dns\",\"value\":\"$_main_domain\"}" |
|
|
for d in $(echo "$_alt_domains" | tr ',' ' '); do |
|
|
|
|
|
if [ "$d" ]; then |
|
|
|
|
|
_identifiers="$_identifiers,{\"type\":\"dns\",\"value\":\"$d\"}" |
|
|
|
|
|
|
|
|
_w_index=1 |
|
|
|
|
|
while true; do |
|
|
|
|
|
d="$(echo "$_alt_domains," | cut -d , -f "$_w_index")" |
|
|
|
|
|
_w_index="$(_math "$_w_index" + 1)" |
|
|
|
|
|
_debug d "$d" |
|
|
|
|
|
if [ -z "$d" ]; then |
|
|
|
|
|
break |
|
|
fi |
|
|
fi |
|
|
|
|
|
_identifiers="$_identifiers,{\"type\":\"dns\",\"value\":\"$d\"}" |
|
|
done |
|
|
done |
|
|
_debug2 _identifiers "$_identifiers" |
|
|
_debug2 _identifiers "$_identifiers" |
|
|
if ! _send_signed_request "$ACME_NEW_ORDER" "{\"identifiers\": [$_identifiers]}"; then |
|
|
if ! _send_signed_request "$ACME_NEW_ORDER" "{\"identifiers\": [$_identifiers]}"; then |
|
@ -3591,6 +3608,8 @@ issue() { |
|
|
_debug2 "_authz_url" "$_authz_url" |
|
|
_debug2 "_authz_url" "$_authz_url" |
|
|
if ! response="$(_get "$_authz_url")"; then |
|
|
if ! response="$(_get "$_authz_url")"; then |
|
|
_err "get to authz error." |
|
|
_err "get to authz error." |
|
|
|
|
|
_err "_authorizations_seg" "$_authorizations_seg" |
|
|
|
|
|
_err "_authz_url" "$_authz_url" |
|
|
_clearup |
|
|
_clearup |
|
|
_on_issue_err "$_post_hook" |
|
|
_on_issue_err "$_post_hook" |
|
|
return 1 |
|
|
return 1 |
|
@ -3609,10 +3628,16 @@ $_authorizations_map" |
|
|
_debug2 _authorizations_map "$_authorizations_map" |
|
|
_debug2 _authorizations_map "$_authorizations_map" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
alldomains=$(echo "$_main_domain,$_alt_domains" | tr ',' ' ') |
|
|
|
|
|
_index=0 |
|
|
_index=0 |
|
|
_currentRoot="" |
|
|
_currentRoot="" |
|
|
for d in $alldomains; do |
|
|
|
|
|
|
|
|
_w_index=1 |
|
|
|
|
|
while true; do |
|
|
|
|
|
d="$(echo "$_main_domain,$_alt_domains," | cut -d , -f "$_w_index")" |
|
|
|
|
|
_w_index="$(_math "$_w_index" + 1)" |
|
|
|
|
|
_debug d "$d" |
|
|
|
|
|
if [ -z "$d" ]; then |
|
|
|
|
|
break |
|
|
|
|
|
fi |
|
|
_info "Getting webroot for domain" "$d" |
|
|
_info "Getting webroot for domain" "$d" |
|
|
_index=$(_math $_index + 1) |
|
|
_index=$(_math $_index + 1) |
|
|
_w="$(echo $_web_roots | cut -d , -f $_index)" |
|
|
_w="$(echo $_web_roots | cut -d , -f $_index)" |
|
@ -3624,7 +3649,7 @@ $_authorizations_map" |
|
|
|
|
|
|
|
|
vtype="$VTYPE_HTTP" |
|
|
vtype="$VTYPE_HTTP" |
|
|
#todo, v2 wildcard force to use dns |
|
|
#todo, v2 wildcard force to use dns |
|
|
if _startswith "$_currentRoot" "dns"; then |
|
|
|
|
|
|
|
|
if _startswith "$_currentRoot" "$W_DNS"; then |
|
|
vtype="$VTYPE_DNS" |
|
|
vtype="$VTYPE_DNS" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
@ -3641,6 +3666,7 @@ $_authorizations_map" |
|
|
_debug2 "response" "$response" |
|
|
_debug2 "response" "$response" |
|
|
if [ -z "$response" ]; then |
|
|
if [ -z "$response" ]; then |
|
|
_err "get to authz error." |
|
|
_err "get to authz error." |
|
|
|
|
|
_err "_authorizations_map" "$_authorizations_map" |
|
|
_clearup |
|
|
_clearup |
|
|
_on_issue_err "$_post_hook" |
|
|
_on_issue_err "$_post_hook" |
|
|
return 1 |
|
|
return 1 |
|
@ -3751,6 +3777,10 @@ $_authorizations_map" |
|
|
if [ "$d_api" ]; then |
|
|
if [ "$d_api" ]; then |
|
|
_info "Found domain api file: $d_api" |
|
|
_info "Found domain api file: $d_api" |
|
|
else |
|
|
else |
|
|
|
|
|
if [ "$_currentRoot" != "$W_DNS" ]; then |
|
|
|
|
|
_err "Can not find dns api hook for: $_currentRoot" |
|
|
|
|
|
_info "You need to add the txt record manually." |
|
|
|
|
|
fi |
|
|
_info "$(__red "Add the following TXT record:")" |
|
|
_info "$(__red "Add the following TXT record:")" |
|
|
_info "$(__red "Domain: '$(__green "$txtdomain")'")" |
|
|
_info "$(__red "Domain: '$(__green "$txtdomain")'")" |
|
|
_info "$(__red "TXT value: '$(__green "$txt")'")" |
|
|
_info "$(__red "TXT value: '$(__green "$txt")'")" |
|
@ -4264,7 +4294,7 @@ renew() { |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
. "$DOMAIN_CONF" |
|
|
. "$DOMAIN_CONF" |
|
|
|
|
|
|
|
|
|
|
|
_debug Le_API "$Le_API" |
|
|
if [ "$Le_API" ]; then |
|
|
if [ "$Le_API" ]; then |
|
|
if [ "$_OLD_CA_HOST" = "$Le_API" ]; then |
|
|
if [ "$_OLD_CA_HOST" = "$Le_API" ]; then |
|
|
export Le_API="$DEFAULT_CA" |
|
|
export Le_API="$DEFAULT_CA" |
|
@ -4868,6 +4898,8 @@ _deactivate() { |
|
|
_debug2 "authzUri" "$authzUri" |
|
|
_debug2 "authzUri" "$authzUri" |
|
|
if ! response="$(_get "$authzUri")"; then |
|
|
if ! response="$(_get "$authzUri")"; then |
|
|
_err "get to authz error." |
|
|
_err "get to authz error." |
|
|
|
|
|
_err "_authorizations_seg" "$_authorizations_seg" |
|
|
|
|
|
_err "authzUri" "$authzUri" |
|
|
_clearup |
|
|
_clearup |
|
|
_on_issue_err "$_post_hook" |
|
|
_on_issue_err "$_post_hook" |
|
|
return 1 |
|
|
return 1 |
|
@ -5779,7 +5811,7 @@ _process() { |
|
|
fi |
|
|
fi |
|
|
;; |
|
|
;; |
|
|
--dns) |
|
|
--dns) |
|
|
wvalue="dns" |
|
|
|
|
|
|
|
|
wvalue="$W_DNS" |
|
|
if [ "$2" ] && ! _startswith "$2" "-"; then |
|
|
if [ "$2" ] && ! _startswith "$2" "-"; then |
|
|
wvalue="$2" |
|
|
wvalue="$2" |
|
|
shift |
|
|
shift |
|
|