|
@@ -1,6 +1,6 @@
|
|
#!/usr/bin/env sh
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
-VER=2.8.0
|
|
|
|
|
|
+VER=2.8.1
|
|
|
|
|
|
PROJECT_NAME="acme.sh"
|
|
PROJECT_NAME="acme.sh"
|
|
|
|
|
|
@@ -35,19 +35,16 @@ _OLD_STAGE_CA_HOST="https://acme-staging.api.letsencrypt.org"
|
|
|
|
|
|
VTYPE_HTTP="http-01"
|
|
VTYPE_HTTP="http-01"
|
|
VTYPE_DNS="dns-01"
|
|
VTYPE_DNS="dns-01"
|
|
-VTYPE_TLS="tls-sni-01"
|
|
|
|
-VTYPE_TLS2="tls-sni-02"
|
|
|
|
VTYPE_ALPN="tls-alpn-01"
|
|
VTYPE_ALPN="tls-alpn-01"
|
|
|
|
|
|
LOCAL_ANY_ADDRESS="0.0.0.0"
|
|
LOCAL_ANY_ADDRESS="0.0.0.0"
|
|
|
|
|
|
-MAX_RENEW=60
|
|
|
|
|
|
+DEFAULT_RENEW=60
|
|
|
|
|
|
DEFAULT_DNS_SLEEP=120
|
|
DEFAULT_DNS_SLEEP=120
|
|
|
|
|
|
NO_VALUE="no"
|
|
NO_VALUE="no"
|
|
|
|
|
|
-W_TLS="tls"
|
|
|
|
W_DNS="dns"
|
|
W_DNS="dns"
|
|
W_ALPN="alpn"
|
|
W_ALPN="alpn"
|
|
DNS_ALIAS_PREFIX="="
|
|
DNS_ALIAS_PREFIX="="
|
|
@@ -1090,7 +1087,7 @@ _createcsr() {
|
|
fi
|
|
fi
|
|
|
|
|
|
if [ "$acmeValidationv1" ]; then
|
|
if [ "$acmeValidationv1" ]; then
|
|
- printf "\n1.3.6.1.5.5.7.1.30.1=critical,DER:04:20:${acmeValidationv1}" >>"${csrconf}"
|
|
|
|
|
|
+ printf "\n1.3.6.1.5.5.7.1.31=critical,DER:04:20:${acmeValidationv1}" >>"${csrconf}"
|
|
fi
|
|
fi
|
|
|
|
|
|
_csr_cn="$(_idn "$domain")"
|
|
_csr_cn="$(_idn "$domain")"
|
|
@@ -1875,11 +1872,7 @@ _send_signed_request() {
|
|
sig="$(printf "%s" "$_sig_t" | _url_replace)"
|
|
sig="$(printf "%s" "$_sig_t" | _url_replace)"
|
|
_debug3 sig "$sig"
|
|
_debug3 sig "$sig"
|
|
|
|
|
|
- if [ "$ACME_VERSION" = "2" ]; then
|
|
|
|
- body="{\"protected\": \"$protected64\", \"payload\": \"$payload64\", \"signature\": \"$sig\"}"
|
|
|
|
- else
|
|
|
|
- body="{\"header\": $JWK_HEADER, \"protected\": \"$protected64\", \"payload\": \"$payload64\", \"signature\": \"$sig\"}"
|
|
|
|
- fi
|
|
|
|
|
|
+ body="{\"protected\": \"$protected64\", \"payload\": \"$payload64\", \"signature\": \"$sig\"}"
|
|
_debug3 body "$body"
|
|
_debug3 body "$body"
|
|
|
|
|
|
response="$(_post "$body" "$url" "$needbase64" "POST" "$__request_conent_type")"
|
|
response="$(_post "$body" "$url" "$needbase64" "POST" "$__request_conent_type")"
|
|
@@ -2926,7 +2919,10 @@ _clearup() {
|
|
|
|
|
|
_clearupdns() {
|
|
_clearupdns() {
|
|
_debug "_clearupdns"
|
|
_debug "_clearupdns"
|
|
- if [ "$dnsadded" != 1 ] || [ -z "$vlist" ]; then
|
|
|
|
|
|
+ _debug "dnsadded" "$dnsadded"
|
|
|
|
+ _debug "vlist" "$vlist"
|
|
|
|
+ #dnsadded is "0" or "1" means dns-01 method was used for at least one domain
|
|
|
|
+ if [ -z "$dnsadded" ] || [ -z "$vlist" ]; then
|
|
_debug "skip dns."
|
|
_debug "skip dns."
|
|
return
|
|
return
|
|
fi
|
|
fi
|
|
@@ -3082,8 +3078,8 @@ _on_before_issue() {
|
|
_savedomainconf "Le_HTTPPort" "$Le_HTTPPort"
|
|
_savedomainconf "Le_HTTPPort" "$Le_HTTPPort"
|
|
fi
|
|
fi
|
|
_checkport="$Le_HTTPPort"
|
|
_checkport="$Le_HTTPPort"
|
|
- elif [ "$_currentRoot" = "$W_TLS" ] || [ "$_currentRoot" = "$W_ALPN" ]; then
|
|
|
|
- _info "Standalone tls/alpn mode."
|
|
|
|
|
|
+ elif [ "$_currentRoot" = "$W_ALPN" ]; then
|
|
|
|
+ _info "Standalone alpn mode."
|
|
if [ -z "$Le_TLSPort" ]; then
|
|
if [ -z "$Le_TLSPort" ]; then
|
|
Le_TLSPort=443
|
|
Le_TLSPort=443
|
|
else
|
|
else
|
|
@@ -3443,15 +3439,17 @@ __get_domain_new_authz() {
|
|
|
|
|
|
#uri keyAuthorization
|
|
#uri keyAuthorization
|
|
__trigger_validation() {
|
|
__trigger_validation() {
|
|
- _debug2 "tigger domain validation."
|
|
|
|
|
|
+ _debug2 "Trigger domain validation."
|
|
_t_url="$1"
|
|
_t_url="$1"
|
|
_debug2 _t_url "$_t_url"
|
|
_debug2 _t_url "$_t_url"
|
|
_t_key_authz="$2"
|
|
_t_key_authz="$2"
|
|
_debug2 _t_key_authz "$_t_key_authz"
|
|
_debug2 _t_key_authz "$_t_key_authz"
|
|
|
|
+ _t_vtype="$3"
|
|
|
|
+ _debug2 _t_vtype "$_t_vtype"
|
|
if [ "$ACME_VERSION" = "2" ]; then
|
|
if [ "$ACME_VERSION" = "2" ]; then
|
|
_send_signed_request "$_t_url" "{\"keyAuthorization\": \"$_t_key_authz\"}"
|
|
_send_signed_request "$_t_url" "{\"keyAuthorization\": \"$_t_key_authz\"}"
|
|
else
|
|
else
|
|
- _send_signed_request "$_t_url" "{\"resource\": \"challenge\", \"keyAuthorization\": \"$_t_key_authz\"}"
|
|
|
|
|
|
+ _send_signed_request "$_t_url" "{\"resource\": \"challenge\", \"type\": \"$_t_vtype\", \"keyAuthorization\": \"$_t_key_authz\"}"
|
|
fi
|
|
fi
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3654,7 +3652,7 @@ issue() {
|
|
_authorizations_map=""
|
|
_authorizations_map=""
|
|
for _authz_url in $(echo "$_authorizations_seg" | tr ',' ' '); do
|
|
for _authz_url in $(echo "$_authorizations_seg" | tr ',' ' '); do
|
|
_debug2 "_authz_url" "$_authz_url"
|
|
_debug2 "_authz_url" "$_authz_url"
|
|
- if ! response="$(_get "$_authz_url")"; then
|
|
|
|
|
|
+ if ! _send_signed_request "$_authz_url"; then
|
|
_err "get to authz error."
|
|
_err "get to authz error."
|
|
_err "_authorizations_seg" "$_authorizations_seg"
|
|
_err "_authorizations_seg" "$_authorizations_seg"
|
|
_err "_authz_url" "$_authz_url"
|
|
_err "_authz_url" "$_authz_url"
|
|
@@ -3701,14 +3699,6 @@ $_authorizations_map"
|
|
vtype="$VTYPE_DNS"
|
|
vtype="$VTYPE_DNS"
|
|
fi
|
|
fi
|
|
|
|
|
|
- if [ "$_currentRoot" = "$W_TLS" ]; then
|
|
|
|
- if [ "$ACME_VERSION" = "2" ]; then
|
|
|
|
- vtype="$VTYPE_TLS2"
|
|
|
|
- else
|
|
|
|
- vtype="$VTYPE_TLS"
|
|
|
|
- fi
|
|
|
|
- fi
|
|
|
|
-
|
|
|
|
if [ "$_currentRoot" = "$W_ALPN" ]; then
|
|
if [ "$_currentRoot" = "$W_ALPN" ]; then
|
|
vtype="$VTYPE_ALPN"
|
|
vtype="$VTYPE_ALPN"
|
|
fi
|
|
fi
|
|
@@ -3861,8 +3851,8 @@ $_authorizations_map"
|
|
)
|
|
)
|
|
|
|
|
|
if [ "$?" != "0" ]; then
|
|
if [ "$?" != "0" ]; then
|
|
- _clearup
|
|
|
|
_on_issue_err "$_post_hook" "$vlist"
|
|
_on_issue_err "$_post_hook" "$vlist"
|
|
|
|
+ _clearup
|
|
return 1
|
|
return 1
|
|
fi
|
|
fi
|
|
dnsadded='1'
|
|
dnsadded='1'
|
|
@@ -3873,8 +3863,8 @@ $_authorizations_map"
|
|
_savedomainconf "Le_Vlist" "$vlist"
|
|
_savedomainconf "Le_Vlist" "$vlist"
|
|
_debug "Dns record not added yet, so, save to $DOMAIN_CONF and exit."
|
|
_debug "Dns record not added yet, so, save to $DOMAIN_CONF and exit."
|
|
_err "Please add the TXT records to the domains, and re-run with --renew."
|
|
_err "Please add the TXT records to the domains, and re-run with --renew."
|
|
- _clearup
|
|
|
|
_on_issue_err "$_post_hook"
|
|
_on_issue_err "$_post_hook"
|
|
|
|
+ _clearup
|
|
return 1
|
|
return 1
|
|
fi
|
|
fi
|
|
|
|
|
|
@@ -3908,7 +3898,7 @@ $_authorizations_map"
|
|
continue
|
|
continue
|
|
fi
|
|
fi
|
|
|
|
|
|
- _info "Verifying:$d"
|
|
|
|
|
|
+ _info "Verifying: $d"
|
|
_debug "d" "$d"
|
|
_debug "d" "$d"
|
|
_debug "keyauthorization" "$keyauthorization"
|
|
_debug "keyauthorization" "$keyauthorization"
|
|
_debug "uri" "$uri"
|
|
_debug "uri" "$uri"
|
|
@@ -3992,40 +3982,6 @@ $_authorizations_map"
|
|
fi
|
|
fi
|
|
|
|
|
|
fi
|
|
fi
|
|
-
|
|
|
|
- elif [ "$vtype" = "$VTYPE_TLS" ]; then
|
|
|
|
- #create A
|
|
|
|
- #_hash_A="$(printf "%s" $token | _digest "sha256" "hex" )"
|
|
|
|
- #_debug2 _hash_A "$_hash_A"
|
|
|
|
- #_x="$(echo $_hash_A | cut -c 1-32)"
|
|
|
|
- #_debug2 _x "$_x"
|
|
|
|
- #_y="$(echo $_hash_A | cut -c 33-64)"
|
|
|
|
- #_debug2 _y "$_y"
|
|
|
|
- #_SAN_A="$_x.$_y.token.acme.invalid"
|
|
|
|
- #_debug2 _SAN_A "$_SAN_A"
|
|
|
|
-
|
|
|
|
- #create B
|
|
|
|
- _hash_B="$(printf "%s" "$keyauthorization" | _digest "sha256" "hex")"
|
|
|
|
- _debug2 _hash_B "$_hash_B"
|
|
|
|
- _x="$(echo "$_hash_B" | cut -c 1-32)"
|
|
|
|
- _debug2 _x "$_x"
|
|
|
|
- _y="$(echo "$_hash_B" | cut -c 33-64)"
|
|
|
|
- _debug2 _y "$_y"
|
|
|
|
-
|
|
|
|
- #_SAN_B="$_x.$_y.ka.acme.invalid"
|
|
|
|
-
|
|
|
|
- _SAN_B="$_x.$_y.acme.invalid"
|
|
|
|
- _debug2 _SAN_B "$_SAN_B"
|
|
|
|
-
|
|
|
|
- _ncaddr="$(_getfield "$_local_addr" "$_ncIndex")"
|
|
|
|
- _ncIndex="$(_math "$_ncIndex" + 1)"
|
|
|
|
- if ! _starttlsserver "$_SAN_B" "$_SAN_A" "$Le_TLSPort" "$keyauthorization" "$_ncaddr"; then
|
|
|
|
- _err "Start tls server error."
|
|
|
|
- _clearupwebbroot "$_currentRoot" "$removelevel" "$token"
|
|
|
|
- _clearup
|
|
|
|
- _on_issue_err "$_post_hook" "$vlist"
|
|
|
|
- return 1
|
|
|
|
- fi
|
|
|
|
elif [ "$vtype" = "$VTYPE_ALPN" ]; then
|
|
elif [ "$vtype" = "$VTYPE_ALPN" ]; then
|
|
acmevalidationv1="$(printf "%s" "$keyauthorization" | _digest "sha256" "hex")"
|
|
acmevalidationv1="$(printf "%s" "$keyauthorization" | _digest "sha256" "hex")"
|
|
_debug acmevalidationv1 "$acmevalidationv1"
|
|
_debug acmevalidationv1 "$acmevalidationv1"
|
|
@@ -4038,7 +3994,7 @@ $_authorizations_map"
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
|
|
- if ! __trigger_validation "$uri" "$keyauthorization"; then
|
|
|
|
|
|
+ if ! __trigger_validation "$uri" "$keyauthorization" "$vtype"; then
|
|
_err "$d:Can not get challenge: $response"
|
|
_err "$d:Can not get challenge: $response"
|
|
_clearupwebbroot "$_currentRoot" "$removelevel" "$token"
|
|
_clearupwebbroot "$_currentRoot" "$removelevel" "$token"
|
|
_clearup
|
|
_clearup
|
|
@@ -4047,7 +4003,7 @@ $_authorizations_map"
|
|
fi
|
|
fi
|
|
|
|
|
|
if [ "$code" ] && [ "$code" != '202' ]; then
|
|
if [ "$code" ] && [ "$code" != '202' ]; then
|
|
- if [ "$ACME_VERSION" = "2" ] && [ "$code" = '200' ]; then
|
|
|
|
|
|
+ if [ "$code" = '200' ]; then
|
|
_debug "trigger validation code: $code"
|
|
_debug "trigger validation code: $code"
|
|
else
|
|
else
|
|
_err "$d:Challenge error: $response"
|
|
_err "$d:Challenge error: $response"
|
|
@@ -4076,7 +4032,11 @@ $_authorizations_map"
|
|
_debug "sleep 2 secs to verify"
|
|
_debug "sleep 2 secs to verify"
|
|
sleep 2
|
|
sleep 2
|
|
_debug "checking"
|
|
_debug "checking"
|
|
- response="$(_get "$uri")"
|
|
|
|
|
|
+ if [ "$ACME_VERSION" = "2" ]; then
|
|
|
|
+ _send_signed_request "$uri"
|
|
|
|
+ else
|
|
|
|
+ response="$(_get "$uri")"
|
|
|
|
+ fi
|
|
if [ "$?" != "0" ]; then
|
|
if [ "$?" != "0" ]; then
|
|
_err "$d:Verify error:$response"
|
|
_err "$d:Verify error:$response"
|
|
_clearupwebbroot "$_currentRoot" "$removelevel" "$token"
|
|
_clearupwebbroot "$_currentRoot" "$removelevel" "$token"
|
|
@@ -4152,13 +4112,16 @@ $_authorizations_map"
|
|
fi
|
|
fi
|
|
Le_LinkCert="$(echo "$response" | tr -d '\r\n' | _egrep_o '"certificate" *: *"[^"]*"' | cut -d '"' -f 4)"
|
|
Le_LinkCert="$(echo "$response" | tr -d '\r\n' | _egrep_o '"certificate" *: *"[^"]*"' | cut -d '"' -f 4)"
|
|
|
|
|
|
- if ! _get "$Le_LinkCert" >"$CERT_PATH"; then
|
|
|
|
|
|
+ _tempSignedResponse="$response"
|
|
|
|
+ if ! _send_signed_request "$Le_LinkCert" "" "needbase64"; then
|
|
_err "Sign failed, can not download cert:$Le_LinkCert."
|
|
_err "Sign failed, can not download cert:$Le_LinkCert."
|
|
_err "$response"
|
|
_err "$response"
|
|
_on_issue_err "$_post_hook"
|
|
_on_issue_err "$_post_hook"
|
|
return 1
|
|
return 1
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
+ echo "$response" | _dbase64 "multiline" >"$CERT_PATH"
|
|
|
|
+
|
|
if [ "$(grep -- "$BEGIN_CERT" "$CERT_PATH" | wc -l)" -gt "1" ]; then
|
|
if [ "$(grep -- "$BEGIN_CERT" "$CERT_PATH" | wc -l)" -gt "1" ]; then
|
|
_debug "Found cert chain"
|
|
_debug "Found cert chain"
|
|
cat "$CERT_PATH" >"$CERT_FULLCHAIN_PATH"
|
|
cat "$CERT_PATH" >"$CERT_FULLCHAIN_PATH"
|
|
@@ -4168,6 +4131,7 @@ $_authorizations_map"
|
|
_end_n="$(_math $_end_n + 1)"
|
|
_end_n="$(_math $_end_n + 1)"
|
|
sed -n "${_end_n},9999p" "$CERT_FULLCHAIN_PATH" >"$CA_CERT_PATH"
|
|
sed -n "${_end_n},9999p" "$CERT_FULLCHAIN_PATH" >"$CA_CERT_PATH"
|
|
fi
|
|
fi
|
|
|
|
+ response="$_tempSignedResponse"
|
|
else
|
|
else
|
|
if ! _send_signed_request "${ACME_NEW_ORDER}" "{\"resource\": \"$ACME_NEW_ORDER_RES\", \"csr\": \"$der\"}" "needbase64"; then
|
|
if ! _send_signed_request "${ACME_NEW_ORDER}" "{\"resource\": \"$ACME_NEW_ORDER_RES\", \"csr\": \"$der\"}" "needbase64"; then
|
|
_err "Sign failed. $response"
|
|
_err "Sign failed. $response"
|
|
@@ -4238,7 +4202,8 @@ $_authorizations_map"
|
|
while [ "$_link_issuer_retry" -lt "$_MAX_ISSUER_RETRY" ]; do
|
|
while [ "$_link_issuer_retry" -lt "$_MAX_ISSUER_RETRY" ]; do
|
|
_debug _link_issuer_retry "$_link_issuer_retry"
|
|
_debug _link_issuer_retry "$_link_issuer_retry"
|
|
if [ "$ACME_VERSION" = "2" ]; then
|
|
if [ "$ACME_VERSION" = "2" ]; then
|
|
- if _get "$Le_LinkIssuer" >"$CA_CERT_PATH"; then
|
|
|
|
|
|
+ if _send_signed_request "$Le_LinkIssuer"; then
|
|
|
|
+ echo "$response" >"$CA_CERT_PATH"
|
|
break
|
|
break
|
|
fi
|
|
fi
|
|
else
|
|
else
|
|
@@ -4274,8 +4239,8 @@ $_authorizations_map"
|
|
Le_CertCreateTimeStr=$(date -u)
|
|
Le_CertCreateTimeStr=$(date -u)
|
|
_savedomainconf "Le_CertCreateTimeStr" "$Le_CertCreateTimeStr"
|
|
_savedomainconf "Le_CertCreateTimeStr" "$Le_CertCreateTimeStr"
|
|
|
|
|
|
- if [ -z "$Le_RenewalDays" ] || [ "$Le_RenewalDays" -lt "0" ] || [ "$Le_RenewalDays" -gt "$MAX_RENEW" ]; then
|
|
|
|
- Le_RenewalDays="$MAX_RENEW"
|
|
|
|
|
|
+ if [ -z "$Le_RenewalDays" ] || [ "$Le_RenewalDays" -lt "0" ]; then
|
|
|
|
+ Le_RenewalDays="$DEFAULT_RENEW"
|
|
else
|
|
else
|
|
_savedomainconf "Le_RenewalDays" "$Le_RenewalDays"
|
|
_savedomainconf "Le_RenewalDays" "$Le_RenewalDays"
|
|
fi
|
|
fi
|
|
@@ -4964,7 +4929,7 @@ _deactivate() {
|
|
|
|
|
|
authzUri="$_authorizations_seg"
|
|
authzUri="$_authorizations_seg"
|
|
_debug2 "authzUri" "$authzUri"
|
|
_debug2 "authzUri" "$authzUri"
|
|
- if ! response="$(_get "$authzUri")"; then
|
|
|
|
|
|
+ if ! _send_signed_request "$authzUri"; then
|
|
_err "get to authz error."
|
|
_err "get to authz error."
|
|
_err "_authorizations_seg" "$_authorizations_seg"
|
|
_err "_authorizations_seg" "$_authorizations_seg"
|
|
_err "authzUri" "$authzUri"
|
|
_err "authzUri" "$authzUri"
|
|
@@ -5527,7 +5492,7 @@ Parameters:
|
|
--useragent Specifies the user agent string. it will be saved for future use too.
|
|
--useragent Specifies the user agent string. it will be saved for future use too.
|
|
--accountemail Specifies the account email, only valid for the '--install' and '--update-account' 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.
|
|
--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.
|
|
|
|
|
|
+ --days Specifies the days to renew the cert when using '--issue' command. The default value is $DEFAULT_RENEW days.
|
|
--httpport Specifies the standalone listening port. Only valid if the server is behind a reverse proxy or load balancer.
|
|
--httpport Specifies the standalone listening port. Only valid if the server is behind a reverse proxy or load balancer.
|
|
--tlsport Specifies the standalone tls listening port. Only valid if the server is behind a reverse proxy or load balancer.
|
|
--tlsport Specifies the standalone tls 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.
|
|
--local-address Specifies the standalone/tls server listening address, in case you have multiple ip addresses.
|