11#! /usr/bin/env sh
22
3- VER=3.0.6
3+ VER=3.0.7
44
55PROJECT_NAME=" acme.sh"
66
@@ -923,8 +923,16 @@ _sed_i() {
923923 fi
924924}
925925
926+ if [ " $( echo abc | egrep -o b 2> /dev/null) " = " b" ]; then
927+ __USE_EGREP=1
928+ else
929+ __USE_EGREP=" "
930+ fi
931+
926932_egrep_o () {
927- if ! egrep -o " $1 " 2> /dev/null; then
933+ if [ " $__USE_EGREP " ]; then
934+ egrep -o " $1 "
935+ else
928936 sed -n ' s/.*\(' " $1 " ' \).*/\1/p'
929937 fi
930938}
@@ -2101,9 +2109,20 @@ _head_n() {
21012109}
21022110
21032111_tail_n () {
2104- if ! tail -n " $1 " 2> /dev/null ; then
2112+ if _is_solaris ; then
21052113 # fix for solaris
21062114 tail -" $1 "
2115+ else
2116+ tail -n " $1 "
2117+ fi
2118+ }
2119+
2120+ _tail_c () {
2121+ if _is_solaris; then
2122+ # fix for solaris
2123+ tail -" $1 " c
2124+ else
2125+ tail -c " $1 "
21072126 fi
21082127}
21092128
@@ -2116,6 +2135,7 @@ _send_signed_request() {
21162135 if [ -z " $keyfile " ]; then
21172136 keyfile=" $ACCOUNT_KEY_PATH "
21182137 fi
2138+ _debug " =======Begin Send Signed Request======="
21192139 _debug url " $url "
21202140 _debug payload " $payload "
21212141
@@ -2277,7 +2297,7 @@ _setopt() {
22772297 if [ ! -f " $__conf " ]; then
22782298 touch " $__conf "
22792299 fi
2280- if [ -n " $( tail -c 1 < " $__conf " ) " ]; then
2300+ if [ -n " $( _tail_c 1 < " $__conf " ) " ]; then
22812301 echo >> " $__conf "
22822302 fi
22832303
@@ -4602,9 +4622,10 @@ issue() {
46024622 _d=" *.$_d "
46034623 fi
46044624 _debug2 _d " $_d "
4605- _authorizations_map=" $_d ,$response
4625+ _authorizations_map=" $_d ,$response # $_authz_url
46064626$_authorizations_map "
46074627 done
4628+
46084629 _debug2 _authorizations_map " $_authorizations_map "
46094630
46104631 _index=0
@@ -4656,7 +4677,8 @@ $_authorizations_map"
46564677 _on_issue_err " $_post_hook "
46574678 return 1
46584679 fi
4659-
4680+ _authz_url=" $( echo " $_candidates " | sed " s/$_idn_d ,//" | _egrep_o " #.*" | sed " s/^#//" ) "
4681+ _debug _authz_url " $_authz_url "
46604682 if [ -z " $thumbprint " ]; then
46614683 thumbprint=" $( __calc_account_thumbprint) "
46624684 fi
@@ -4708,7 +4730,7 @@ $_authorizations_map"
47084730 _debug keyauthorization " $keyauthorization "
47094731 fi
47104732
4711- dvlist=" $d$sep$keyauthorization$sep$uri$sep$vtype$sep$_currentRoot "
4733+ dvlist=" $d$sep$keyauthorization$sep$uri$sep$vtype$sep$_currentRoot$sep$_authz_url "
47124734 _debug dvlist " $dvlist "
47134735
47144736 vlist=" $vlist$dvlist$dvsep "
@@ -4725,6 +4747,7 @@ $_authorizations_map"
47254747 keyauthorization=$( echo " $ventry " | cut -d " $sep " -f 2)
47264748 vtype=$( echo " $ventry " | cut -d " $sep " -f 4)
47274749 _currentRoot=$( echo " $ventry " | cut -d " $sep " -f 5)
4750+ _authz_url=$( echo " $ventry " | cut -d " $sep " -f 6)
47284751 _debug d " $d "
47294752 if [ " $keyauthorization " = " $STATE_VERIFIED " ]; then
47304753 _debug " $d is already verified, skip $vtype ."
@@ -4850,7 +4873,7 @@ $_authorizations_map"
48504873 uri=$( echo " $ventry " | cut -d " $sep " -f 3)
48514874 vtype=$( echo " $ventry " | cut -d " $sep " -f 4)
48524875 _currentRoot=$( echo " $ventry " | cut -d " $sep " -f 5)
4853-
4876+ _authz_url= $( echo " $ventry " | cut -d " $sep " -f 6 )
48544877 if [ " $keyauthorization " = " $STATE_VERIFIED " ]; then
48554878 _info " $d is already verified, skip $vtype ."
48564879 continue
@@ -4860,6 +4883,7 @@ $_authorizations_map"
48604883 _debug " d" " $d "
48614884 _debug " keyauthorization" " $keyauthorization "
48624885 _debug " uri" " $uri "
4886+ _debug " _authz_url" " $_authz_url "
48634887 removelevel=" "
48644888 token=" $( printf " %s" " $keyauthorization " | cut -d ' .' -f 1) "
48654889
@@ -4967,6 +4991,7 @@ $_authorizations_map"
49674991 MAX_RETRY_TIMES=30
49684992 fi
49694993
4994+ _debug " Lets check the status of the authz"
49704995 while true ; do
49714996 waittimes=$( _math " $waittimes " + 1)
49724997 if [ " $waittimes " -ge " $MAX_RETRY_TIMES " ]; then
@@ -5014,9 +5039,9 @@ $_authorizations_map"
50145039 break
50155040 fi
50165041
5017- if [ " $status " = " pending" ] ; then
5042+ if _contains " $status " " pending" ; then
50185043 _info " Pending, The CA is processing your order, please just wait. ($waittimes /$MAX_RETRY_TIMES )"
5019- elif [ " $status " = " processing" ] ; then
5044+ elif _contains " $status " " processing" ; then
50205045 _info " Processing, The CA is processing your order, please just wait. ($waittimes /$MAX_RETRY_TIMES )"
50215046 else
50225047 _err " $d :Verify error:$response "
@@ -5029,7 +5054,7 @@ $_authorizations_map"
50295054 _sleep 2
50305055 _debug " checking"
50315056
5032- _send_signed_request " $uri "
5057+ _send_signed_request " $_authz_url "
50335058
50345059 if [ " $? " != " 0" ]; then
50355060 _err " $d :Verify error:$response "
0 commit comments