|
@@ -110,10 +110,14 @@ _STATELESS_WIKI="https://github.com/Neilpang/acme.sh/wiki/Stateless-Mode"
|
|
|
|
|
|
_DNS_ALIAS_WIKI="https://github.com/Neilpang/acme.sh/wiki/DNS-alias-mode"
|
|
|
|
|
|
+_DNS_MANUAL_WIKI="https://github.com/Neilpang/acme.sh/wiki/dns-manual-mode"
|
|
|
+
|
|
|
_DNS_MANUAL_ERR="The dns manual mode can not renew automatically, you must issue it again manually. You'd better use the other modes instead."
|
|
|
|
|
|
_DNS_MANUAL_WARN="It seems that you are using dns manual mode. please take care: $_DNS_MANUAL_ERR"
|
|
|
|
|
|
+_DNS_MANUAL_ERROR="It seems that you are using dns manual mode. Read this link first: $_DNS_MANUAL_WIKI"
|
|
|
+
|
|
|
__INTERACTIVE=""
|
|
|
if [ -t 1 ]; then
|
|
|
__INTERACTIVE="1"
|
|
@@ -1617,6 +1621,7 @@ _post() {
|
|
|
_debug $httpmethod
|
|
|
_debug "_post_url" "$_post_url"
|
|
|
_debug2 "body" "$body"
|
|
|
+ _debug2 "_postContentType" "$_postContentType"
|
|
|
|
|
|
_inithttp
|
|
|
|
|
@@ -1625,14 +1630,19 @@ _post() {
|
|
|
if [ "$HTTPS_INSECURE" ]; then
|
|
|
_CURL="$_CURL --insecure "
|
|
|
fi
|
|
|
- if [ "$_postContentType" ]; then
|
|
|
- _CURL="$_CURL -H \"Content-Type: $_postContentType\" "
|
|
|
- fi
|
|
|
_debug "_CURL" "$_CURL"
|
|
|
if [ "$needbase64" ]; then
|
|
|
- response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" --data "$body" "$_post_url" | _base64)"
|
|
|
+ if [ "$_postContentType" ]; then
|
|
|
+ response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "Content-Type: $_postContentType" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" --data "$body" "$_post_url" | _base64)"
|
|
|
+ else
|
|
|
+ response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" --data "$body" "$_post_url" | _base64)"
|
|
|
+ fi
|
|
|
else
|
|
|
- response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" --data "$body" "$_post_url")"
|
|
|
+ if [ "$_postContentType" ]; then
|
|
|
+ response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "Content-Type: $_postContentType" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" --data "$body" "$_post_url")"
|
|
|
+ else
|
|
|
+ response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" --data "$body" "$_post_url")"
|
|
|
+ fi
|
|
|
fi
|
|
|
_ret="$?"
|
|
|
if [ "$_ret" != "0" ]; then
|
|
@@ -1785,19 +1795,25 @@ _send_signed_request() {
|
|
|
return 1
|
|
|
fi
|
|
|
|
|
|
+ if [ "$ACME_VERSION" = "2" ]; then
|
|
|
+ __request_conent_type="$CONTENT_TYPE_JSON"
|
|
|
+ else
|
|
|
+ __request_conent_type=""
|
|
|
+ fi
|
|
|
payload64=$(printf "%s" "$payload" | _base64 | _url_replace)
|
|
|
_debug3 payload64 "$payload64"
|
|
|
|
|
|
MAX_REQUEST_RETRY_TIMES=5
|
|
|
_request_retry_times=0
|
|
|
while [ "${_request_retry_times}" -lt "$MAX_REQUEST_RETRY_TIMES" ]; do
|
|
|
+ _request_retry_times=$(_math "$_request_retry_times" + 1)
|
|
|
_debug3 _request_retry_times "$_request_retry_times"
|
|
|
if [ -z "$_CACHED_NONCE" ]; then
|
|
|
_headers=""
|
|
|
if [ "$ACME_NEW_NONCE" ]; then
|
|
|
_debug2 "Get nonce. ACME_NEW_NONCE" "$ACME_NEW_NONCE"
|
|
|
nonceurl="$ACME_NEW_NONCE"
|
|
|
- if _post "" "$nonceurl" "" "HEAD" "$CONTENT_TYPE_JSON"; then
|
|
|
+ if _post "" "$nonceurl" "" "HEAD" "$__request_conent_type"; then
|
|
|
_headers="$(cat "$HTTP_HEADER")"
|
|
|
fi
|
|
|
fi
|
|
@@ -1821,7 +1837,11 @@ _send_signed_request() {
|
|
|
fi
|
|
|
nonce="$_CACHED_NONCE"
|
|
|
_debug2 nonce "$nonce"
|
|
|
-
|
|
|
+ if [ -z "$nonce" ]; then
|
|
|
+ _info "Could not get nonce, let's try again."
|
|
|
+ _sleep 2
|
|
|
+ continue
|
|
|
+ fi
|
|
|
if [ "$ACME_VERSION" = "2" ]; then
|
|
|
if [ "$url" = "$ACME_NEW_ACCOUNT" ] || [ "$url" = "$ACME_REVOKE_CERT" ]; then
|
|
|
protected="$JWK_HEADERPLACE_PART1$nonce\", \"url\": \"${url}$JWK_HEADERPLACE_PART2, \"jwk\": $jwk"'}'
|
|
@@ -1852,7 +1872,7 @@ _send_signed_request() {
|
|
|
fi
|
|
|
_debug3 body "$body"
|
|
|
|
|
|
- response="$(_post "$body" "$url" "$needbase64" "POST" "$CONTENT_TYPE_JSON")"
|
|
|
+ response="$(_post "$body" "$url" "$needbase64" "POST" "$__request_conent_type")"
|
|
|
_CACHED_NONCE=""
|
|
|
|
|
|
if [ "$?" != "0" ]; then
|
|
@@ -1879,7 +1899,6 @@ _send_signed_request() {
|
|
|
|
|
|
if _contains "$_body" "JWS has invalid anti-replay nonce"; then
|
|
|
_info "It seems the CA server is busy now, let's wait and retry."
|
|
|
- _request_retry_times=$(_math "$_request_retry_times" + 1)
|
|
|
_sleep 5
|
|
|
continue
|
|
|
fi
|
|
@@ -3247,10 +3266,16 @@ _regAccount() {
|
|
|
return 1
|
|
|
fi
|
|
|
|
|
|
+ _debug2 responseHeaders "$responseHeaders"
|
|
|
_accUri="$(echo "$responseHeaders" | grep "^Location:" | _head_n 1 | cut -d ' ' -f 2 | tr -d "\r\n")"
|
|
|
_debug "_accUri" "$_accUri"
|
|
|
+ if [ -z "$_accUri" ]; then
|
|
|
+ _err "Can not find account id url."
|
|
|
+ _err "$responseHeaders"
|
|
|
+ return 1
|
|
|
+ fi
|
|
|
_savecaconf "ACCOUNT_URL" "$_accUri"
|
|
|
- export ACCOUNT_URL="$ACCOUNT_URL"
|
|
|
+ export ACCOUNT_URL="$_accUri"
|
|
|
|
|
|
CA_KEY_HASH="$(__calcAccountKeyHash)"
|
|
|
_debug "Calc CA_KEY_HASH" "$CA_KEY_HASH"
|
|
@@ -3460,6 +3485,11 @@ issue() {
|
|
|
mkdir -p "$DOMAIN_PATH"
|
|
|
fi
|
|
|
|
|
|
+ if _hasfield "$_web_roots" "$W_DNS" && [ -z "$FORCE_DNS_MANUAL" ]; then
|
|
|
+ _err "$_DNS_MANUAL_ERROR"
|
|
|
+ return 1
|
|
|
+ fi
|
|
|
+
|
|
|
_debug "Using ACME_DIRECTORY: $ACME_DIRECTORY"
|
|
|
|
|
|
_initAPI
|
|
@@ -3521,7 +3551,7 @@ issue() {
|
|
|
_saved_account_key_hash="$(_readcaconf "CA_KEY_HASH")"
|
|
|
_debug2 _saved_account_key_hash "$_saved_account_key_hash"
|
|
|
|
|
|
- if [ -z "$_saved_account_key_hash" ] || [ "$_saved_account_key_hash" != "$(__calcAccountKeyHash)" ]; then
|
|
|
+ if [ -z "$ACCOUNT_URL" ] || [ -z "$_saved_account_key_hash" ] || [ "$_saved_account_key_hash" != "$(__calcAccountKeyHash)" ]; then
|
|
|
if ! _regAccount "$_accountkeylength"; then
|
|
|
_on_issue_err "$_post_hook"
|
|
|
return 1
|
|
@@ -3819,7 +3849,7 @@ $_authorizations_map"
|
|
|
if [ "$dnsadded" = '0' ]; then
|
|
|
_savedomainconf "Le_Vlist" "$vlist"
|
|
|
_debug "Dns record not added yet, so, save to $DOMAIN_CONF and exit."
|
|
|
- _err "Please add the TXT records to the domains, and retry again."
|
|
|
+ _err "Please add the TXT records to the domains, and re-run with --renew."
|
|
|
_clearup
|
|
|
_on_issue_err "$_post_hook"
|
|
|
return 1
|
|
@@ -4083,13 +4113,15 @@ $_authorizations_map"
|
|
|
fi
|
|
|
if [ "$code" != "200" ]; then
|
|
|
_err "Sign failed, code is not 200."
|
|
|
+ _err "$response"
|
|
|
_on_issue_err "$_post_hook"
|
|
|
return 1
|
|
|
fi
|
|
|
Le_LinkCert="$(echo "$response" | tr -d '\r\n' | _egrep_o '"certificate" *: *"[^"]*"' | cut -d '"' -f 4)"
|
|
|
|
|
|
if ! _get "$Le_LinkCert" >"$CERT_PATH"; then
|
|
|
- _err "Sign failed, code is not 200."
|
|
|
+ _err "Sign failed, can not download cert:$Le_LinkCert."
|
|
|
+ _err "$response"
|
|
|
_on_issue_err "$_post_hook"
|
|
|
return 1
|
|
|
fi
|
|
@@ -4105,12 +4137,12 @@ $_authorizations_map"
|
|
|
fi
|
|
|
else
|
|
|
if ! _send_signed_request "${ACME_NEW_ORDER}" "{\"resource\": \"$ACME_NEW_ORDER_RES\", \"csr\": \"$der\"}" "needbase64"; then
|
|
|
- _err "Sign failed."
|
|
|
+ _err "Sign failed. $response"
|
|
|
_on_issue_err "$_post_hook"
|
|
|
return 1
|
|
|
fi
|
|
|
_rcert="$response"
|
|
|
- Le_LinkCert="$(grep -i '^Location.*$' "$HTTP_HEADER" | _head_n 1 | tr -d "\r\n" | cut -d " " -f 2)"
|
|
|
+ Le_LinkCert="$(grep -i '^Location.*$' "$HTTP_HEADER" | _tail_n 1 | tr -d "\r\n" | cut -d " " -f 2)"
|
|
|
echo "$BEGIN_CERT" >"$CERT_PATH"
|
|
|
|
|
|
#if ! _get "$Le_LinkCert" | _base64 "multiline" >> "$CERT_PATH" ; then
|
|
@@ -5456,8 +5488,8 @@ Parameters:
|
|
|
--cert-home Specifies the home dir to save all the certs, only valid for '--install' command.
|
|
|
--config-home Specifies the home dir to save all the configurations.
|
|
|
--useragent Specifies the user agent string. it will be saved for future use too.
|
|
|
- --accountemail Specifies the account email for registering, Only valid for the '--install' command.
|
|
|
- --accountkey Specifies the account key path, Only valid for the '--install' command.
|
|
|
+ --accountemail Specifies the account email, only valid for the '--install' and '--update-account' command.
|
|
|
+ --accountkey Specifies the account key path, only valid for the '--install' command.
|
|
|
--days Specifies the days to renew the cert when using '--issue' command. The max value is $MAX_RENEW days.
|
|
|
--httpport Specifies the standalone listening port. Only valid if the server is behind a reverse proxy or load balancer.
|
|
|
--local-address Specifies the standalone/tls server listening address, in case you have multiple ip addresses.
|
|
@@ -5481,6 +5513,7 @@ Parameters:
|
|
|
--listen-v6 Force standalone/tls server to listen at ipv6.
|
|
|
--openssl-bin Specifies a custom openssl bin location.
|
|
|
--use-wget Force to use wget, if you have both curl and wget installed.
|
|
|
+ --yes-I-know-dns-manual-mode-enough-go-ahead-please Force to use dns manual mode: $_DNS_MANUAL_WIKI
|
|
|
"
|
|
|
}
|
|
|
|
|
@@ -5969,6 +6002,9 @@ _process() {
|
|
|
shift
|
|
|
fi
|
|
|
;;
|
|
|
+ --yes-I-know-dns-manual-mode-enough-go-ahead-please)
|
|
|
+ export FORCE_DNS_MANUAL=1
|
|
|
+ ;;
|
|
|
--log | --logfile)
|
|
|
_log="1"
|
|
|
_logfile="$2"
|