Changeset 79f7e49


Ignore:
Timestamp:
01/18/22 12:47:03 (3 years ago)
Author:
Edwin Eefting <edwin@datux.nl>
Branches:
master
Children:
39a3656
Parents:
3daa803
Message:

acmeupdate

Location:
npl/syn3/acme
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • npl/syn3/acme/root/usr/bin/acme.sh

    r3daa803 r79f7e49  
    11#!/usr/bin/env sh
    22
    3 VER=3.0.1
     3VER=2.8.8
    44
    55PROJECT_NAME="acme.sh"
     
    2121_SUB_FOLDERS="$_SUB_FOLDER_DNSAPI $_SUB_FOLDER_DEPLOY $_SUB_FOLDER_NOTIFY"
    2222
    23 CA_LETSENCRYPT_V1="https://acme-v01.api.letsencrypt.org/directory"
     23LETSENCRYPT_CA_V1="https://acme-v01.api.letsencrypt.org/directory"
     24LETSENCRYPT_STAGING_CA_V1="https://acme-staging.api.letsencrypt.org/directory"
    2425
    2526CA_LETSENCRYPT_V2="https://acme-v02.api.letsencrypt.org/directory"
     
    3233_ZERO_EAB_ENDPOINT="http://api.zerossl.com/acme/eab-credentials-email"
    3334
    34 CA_SSLCOM_RSA="https://acme.ssl.com/sslcom-dv-rsa"
    35 CA_SSLCOM_ECC="https://acme.ssl.com/sslcom-dv-ecc"
    36 
    37 DEFAULT_CA=$CA_ZEROSSL
     35DEFAULT_CA=$CA_LETSENCRYPT_V2
    3836DEFAULT_STAGING_CA=$CA_LETSENCRYPT_V2_TEST
    3937
    4038CA_NAMES="
    41 ZeroSSL.com,zerossl
    4239LetsEncrypt.org,letsencrypt
    4340LetsEncrypt.org_test,letsencrypt_test,letsencrypttest
    4441BuyPass.com,buypass
    4542BuyPass.com_test,buypass_test,buypasstest
    46 SSL.com,sslcom
     43ZeroSSL.com,zerossl
    4744"
    4845
    49 CA_SERVERS="$CA_ZEROSSL,$CA_LETSENCRYPT_V2,$CA_LETSENCRYPT_V2_TEST,$CA_BUYPASS,$CA_BUYPASS_TEST,$CA_SSLCOM_RSA"
     46CA_SERVERS="$CA_LETSENCRYPT_V2,$CA_LETSENCRYPT_V2_TEST,$CA_BUYPASS,$CA_BUYPASS_TEST,$CA_ZEROSSL"
    5047
    5148DEFAULT_USER_AGENT="$PROJECT_NAME/$VER ($PROJECT)"
     
    106103DOH_CLOUDFLARE=1
    107104DOH_GOOGLE=2
    108 DOH_ALI=3
    109 DOH_DP=4
    110105
    111106HIDDEN_VALUE="[hidden](please add '--output-insecure' to see this value)"
     
    162157_ZEROSSL_WIKI="https://github.com/acmesh-official/acme.sh/wiki/ZeroSSL.com-CA"
    163158
    164 _SSLCOM_WIKI="https://github.com/acmesh-official/acme.sh/wiki/SSL.com-CA"
    165 
    166159_SERVER_WIKI="https://github.com/acmesh-official/acme.sh/wiki/Server"
    167160
    168161_PREFERRED_CHAIN_WIKI="https://github.com/acmesh-official/acme.sh/wiki/Preferred-Chain"
    169 
    170 _DNSCHECK_WIKI="https://github.com/acmesh-official/acme.sh/wiki/dnscheck"
    171162
    172163_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."
     
    570561
    571562_h2b() {
    572   if _exists xxd; then
    573     if _contains "$(xxd --help 2>&1)" "assumes -c30"; then
    574       if xxd -r -p -c 9999 2>/dev/null; then
    575         return
    576       fi
    577     else
    578       if xxd -r -p 2>/dev/null; then
    579         return
    580       fi
    581     fi
     563  if _exists xxd && xxd -r -p 2>/dev/null; then
     564    return
    582565  fi
    583566
     
    11401123  if _isEccKey "$length"; then
    11411124    _debug "Using ec name: $eccname"
    1142     if _opkey="$(${ACME_OPENSSL_BIN:-openssl} ecparam -name "$eccname" -noout -genkey 2>/dev/null)"; then
     1125    if _opkey="$(${ACME_OPENSSL_BIN:-openssl} ecparam -name "$eccname" -genkey 2>/dev/null)"; then
    11431126      echo "$_opkey" >"$f"
    11441127    else
     
    11481131  else
    11491132    _debug "Using RSA: $length"
    1150     __traditional=""
    1151     if _contains "$(${ACME_OPENSSL_BIN:-openssl} help genrsa 2>&1)" "-traditional"; then
    1152       __traditional="-traditional"
    1153     fi
    1154     if _opkey="$(${ACME_OPENSSL_BIN:-openssl} genrsa $__traditional "$length" 2>/dev/null)"; then
     1133    if _opkey="$(${ACME_OPENSSL_BIN:-openssl} genrsa "$length" 2>/dev/null)"; then
    11551134      echo "$_opkey" >"$f"
    11561135    else
     
    12191198  _debug2 csrconf "$csrconf"
    12201199
    1221   printf "[ req_distinguished_name ]\n[ req ]\ndistinguished_name = req_distinguished_name\nreq_extensions = v3_req\n[ v3_req ]\n\n" >"$csrconf"
     1200  printf "[ req_distinguished_name ]\n[ req ]\ndistinguished_name = req_distinguished_name\nreq_extensions = v3_req\n[ v3_req ]\n\nkeyUsage = nonRepudiation, digitalSignature, keyEncipherment" >"$csrconf"
    12221201
    12231202  if [ "$acmeValidationv1" ]; then
     
    17711750      _ACME_CURL="$_ACME_CURL -L "
    17721751    fi
    1773     if [ "$DEBUG" ] && [ "$DEBUG" -ge 2 ]; then
     1752    if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ]; then
    17741753      _CURL_DUMP="$(_mktemp)"
    17751754      _ACME_CURL="$_ACME_CURL --trace-ascii $_CURL_DUMP "
     
    18101789
    18111790}
    1812 
    1813 _HTTP_MAX_RETRY=8
    18141791
    18151792# body  url [needbase64] [POST|PUT|DELETE] [ContentType]
     
    18201797  httpmethod="$4"
    18211798  _postContentType="$5"
    1822   _sleep_retry_sec=1
    1823   _http_retry_times=0
    1824   _hcode=0
    1825   while [ "${_http_retry_times}" -le "$_HTTP_MAX_RETRY" ]; do
    1826     [ "$_http_retry_times" = "$_HTTP_MAX_RETRY" ]
    1827     _lastHCode="$?"
    1828     _debug "Retrying post"
    1829     _post_impl "$body" "$_post_url" "$needbase64" "$httpmethod" "$_postContentType" "$_lastHCode"
    1830     _hcode="$?"
    1831     _debug _hcode "$_hcode"
    1832     if [ "$_hcode" = "0" ]; then
    1833       break
    1834     fi
    1835     _http_retry_times=$(_math $_http_retry_times + 1)
    1836     _sleep $_sleep_retry_sec
    1837   done
    1838   return $_hcode
    1839 }
    1840 
    1841 # body  url [needbase64] [POST|PUT|DELETE] [ContentType] [displayError]
    1842 _post_impl() {
    1843   body="$1"
    1844   _post_url="$2"
    1845   needbase64="$3"
    1846   httpmethod="$4"
    1847   _postContentType="$5"
    1848   displayError="$6"
    18491799
    18501800  if [ -z "$httpmethod" ]; then
     
    18981848    _ret="$?"
    18991849    if [ "$_ret" != "0" ]; then
    1900       if [ -z "$displayError" ] || [ "$displayError" = "0" ]; then
    1901         _err "Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: $_ret"
    1902       fi
     1850      _err "Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: $_ret"
    19031851      if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ]; then
    19041852        _err "Here is the curl dump log:"
     
    19561904    fi
    19571905    if [ "$_ret" != "0" ]; then
    1958       if [ -z "$displayError" ] || [ "$displayError" = "0" ]; then
    1959         _err "Please refer to https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html for error code: $_ret"
    1960       fi
     1906      _err "Please refer to https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html for error code: $_ret"
    19611907    fi
    19621908    _sed_i "s/^ *//g" "$HTTP_HEADER"
     
    19721918# url getheader timeout
    19731919_get() {
    1974   url="$1"
    1975   onlyheader="$2"
    1976   t="$3"
    1977   _sleep_retry_sec=1
    1978   _http_retry_times=0
    1979   _hcode=0
    1980   while [ "${_http_retry_times}" -le "$_HTTP_MAX_RETRY" ]; do
    1981     [ "$_http_retry_times" = "$_HTTP_MAX_RETRY" ]
    1982     _lastHCode="$?"
    1983     _debug "Retrying GET"
    1984     _get_impl "$url" "$onlyheader" "$t" "$_lastHCode"
    1985     _hcode="$?"
    1986     _debug _hcode "$_hcode"
    1987     if [ "$_hcode" = "0" ]; then
    1988       break
    1989     fi
    1990     _http_retry_times=$(_math $_http_retry_times + 1)
    1991     _sleep $_sleep_retry_sec
    1992   done
    1993   return $_hcode
    1994 }
    1995 
    1996 # url getheader timeout displayError
    1997 _get_impl() {
    19981920  _debug GET
    19991921  url="$1"
    20001922  onlyheader="$2"
    20011923  t="$3"
    2002   displayError="$4"
    20031924  _debug url "$url"
    20041925  _debug "timeout=$t"
    2005   _debug "displayError" "$displayError"
     1926
    20061927  _inithttp
    20071928
     
    20221943    ret=$?
    20231944    if [ "$ret" != "0" ]; then
    2024       if [ -z "$displayError" ] || [ "$displayError" = "0" ]; then
    2025         _err "Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: $ret"
    2026       fi
     1945      _err "Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: $ret"
    20271946      if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ]; then
    20281947        _err "Here is the curl dump log:"
     
    20501969    fi
    20511970    if [ "$ret" != "0" ]; then
    2052       if [ -z "$displayError" ] || [ "$displayError" = "0" ]; then
    2053         _err "Please refer to https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html for error code: $ret"
    2054       fi
     1971      _err "Please refer to https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html for error code: $ret"
    20551972    fi
    20561973  else
     
    21082025          _headers="$(cat "$HTTP_HEADER")"
    21092026          _debug2 _headers "$_headers"
    2110           _CACHED_NONCE="$(echo "$_headers" | grep -i "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2 | cut -d , -f 1)"
     2027          _CACHED_NONCE="$(echo "$_headers" | grep -i "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2)"
    21112028        fi
    21122029      fi
     
    21402057      continue
    21412058    fi
    2142 
    2143     if [ "$url" = "$ACME_NEW_ACCOUNT" ]; then
     2059    if [ "$ACME_VERSION" = "2" ]; then
     2060      if [ "$url" = "$ACME_NEW_ACCOUNT" ]; then
     2061        protected="$JWK_HEADERPLACE_PART1$nonce\", \"url\": \"${url}$JWK_HEADERPLACE_PART2, \"jwk\": $jwk"'}'
     2062      elif [ "$url" = "$ACME_REVOKE_CERT" ] && [ "$keyfile" != "$ACCOUNT_KEY_PATH" ]; then
     2063        protected="$JWK_HEADERPLACE_PART1$nonce\", \"url\": \"${url}$JWK_HEADERPLACE_PART2, \"jwk\": $jwk"'}'
     2064      else
     2065        protected="$JWK_HEADERPLACE_PART1$nonce\", \"url\": \"${url}$JWK_HEADERPLACE_PART2, \"kid\": \"${ACCOUNT_URL}\""'}'
     2066      fi
     2067    else
    21442068      protected="$JWK_HEADERPLACE_PART1$nonce\", \"url\": \"${url}$JWK_HEADERPLACE_PART2, \"jwk\": $jwk"'}'
    2145     elif [ "$url" = "$ACME_REVOKE_CERT" ] && [ "$keyfile" != "$ACCOUNT_KEY_PATH" ]; then
    2146       protected="$JWK_HEADERPLACE_PART1$nonce\", \"url\": \"${url}$JWK_HEADERPLACE_PART2, \"jwk\": $jwk"'}'
    2147     else
    2148       protected="$JWK_HEADERPLACE_PART1$nonce\", \"url\": \"${url}$JWK_HEADERPLACE_PART2, \"kid\": \"${ACCOUNT_URL}\""'}'
    2149     fi
    2150 
     2069    fi
    21512070    _debug3 protected "$protected"
    21522071
     
    21862105    _debug2 response "$response"
    21872106
    2188     _CACHED_NONCE="$(echo "$responseHeaders" | grep -i "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2 | cut -d , -f 1)"
     2107    _CACHED_NONCE="$(echo "$responseHeaders" | grep -i "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2)"
    21892108
    21902109    if ! _startswith "$code" "2"; then
     
    21972116      if _contains "$_body" "JWS has invalid anti-replay nonce" || _contains "$_body" "JWS has an invalid anti-replay nonce"; then
    21982117        _info "It seems the CA server is busy now, let's wait and retry. Sleeping $_sleep_retry_sec seconds."
    2199         _CACHED_NONCE=""
    2200         _sleep $_sleep_retry_sec
    2201         continue
    2202       fi
    2203       if _contains "$_body" "The Replay Nonce is not recognized"; then
    2204         _info "The replay Nonce is not valid, let's get a new one, Sleeping $_sleep_retry_sec seconds."
    22052118        _CACHED_NONCE=""
    22062119        _sleep $_sleep_retry_sec
     
    23342247  fi
    23352248  _saved=$(_readdomainconf "SAVED_$_rac_key")
    2336   eval "export $_rac_key=\"\$_saved\""
     2249  eval "export $_rac_key=\"$_saved\""
    23372250}
    23382251
     
    23632276_clearaccountconf() {
    23642277  _clear_conf "$ACCOUNT_CONF_PATH" "$1"
    2365 }
    2366 
    2367 #key
    2368 _clearaccountconf_mutable() {
    2369   _clearaccountconf "SAVED_$1"
    2370   #remove later
    2371   _clearaccountconf "$1"
    23722278}
    23732279
     
    24252331echo 'Content-Length\: $_content_len'; \
    24262332echo ''; \
    2427 printf '%s' '$content';" &
     2333printf -- '$content';" &
    24282334  serverproc="$!"
    24292335}
     
    26002506}
    26012507
    2602 _clearAPI() {
    2603   ACME_NEW_ACCOUNT=""
    2604   ACME_KEY_CHANGE=""
    2605   ACME_NEW_AUTHZ=""
    2606   ACME_NEW_ORDER=""
    2607   ACME_REVOKE_CERT=""
    2608   ACME_NEW_NONCE=""
    2609   ACME_AGREEMENT=""
    2610 }
    2611 
    26122508#server
    26132509_initAPI() {
     
    26152511  _debug "_init api for server: $_api_server"
    26162512
    2617   MAX_API_RETRY_TIMES=10
    2618   _sleep_retry_sec=10
    2619   _request_retry_times=0
    2620   while [ -z "$ACME_NEW_ACCOUNT" ] && [ "${_request_retry_times}" -lt "$MAX_API_RETRY_TIMES" ]; do
    2621     _request_retry_times=$(_math "$_request_retry_times" + 1)
     2513  if [ -z "$ACME_NEW_ACCOUNT" ]; then
    26222514    response=$(_get "$_api_server")
    26232515    if [ "$?" != "0" ]; then
    26242516      _debug2 "response" "$response"
    2625       _info "Can not init api for: $_api_server."
    2626       _info "Sleep $_sleep_retry_sec and retry."
    2627       _sleep "$_sleep_retry_sec"
    2628       continue
     2517      _err "Can not init api."
     2518      return 1
    26292519    fi
    26302520    response=$(echo "$response" | _json_decode)
    26312521    _debug2 "response" "$response"
    26322522
    2633     ACME_KEY_CHANGE=$(echo "$response" | _egrep_o 'keyChange" *: *"[^"]*"' | cut -d '"' -f 3)
     2523    ACME_KEY_CHANGE=$(echo "$response" | _egrep_o 'key-change" *: *"[^"]*"' | cut -d '"' -f 3)
     2524    if [ -z "$ACME_KEY_CHANGE" ]; then
     2525      ACME_KEY_CHANGE=$(echo "$response" | _egrep_o 'keyChange" *: *"[^"]*"' | cut -d '"' -f 3)
     2526    fi
    26342527    export ACME_KEY_CHANGE
    26352528
    2636     ACME_NEW_AUTHZ=$(echo "$response" | _egrep_o 'newAuthz" *: *"[^"]*"' | cut -d '"' -f 3)
     2529    ACME_NEW_AUTHZ=$(echo "$response" | _egrep_o 'new-authz" *: *"[^"]*"' | cut -d '"' -f 3)
     2530    if [ -z "$ACME_NEW_AUTHZ" ]; then
     2531      ACME_NEW_AUTHZ=$(echo "$response" | _egrep_o 'newAuthz" *: *"[^"]*"' | cut -d '"' -f 3)
     2532    fi
    26372533    export ACME_NEW_AUTHZ
    26382534
    2639     ACME_NEW_ORDER=$(echo "$response" | _egrep_o 'newOrder" *: *"[^"]*"' | cut -d '"' -f 3)
     2535    ACME_NEW_ORDER=$(echo "$response" | _egrep_o 'new-cert" *: *"[^"]*"' | cut -d '"' -f 3)
     2536    ACME_NEW_ORDER_RES="new-cert"
     2537    if [ -z "$ACME_NEW_ORDER" ]; then
     2538      ACME_NEW_ORDER=$(echo "$response" | _egrep_o 'new-order" *: *"[^"]*"' | cut -d '"' -f 3)
     2539      ACME_NEW_ORDER_RES="new-order"
     2540      if [ -z "$ACME_NEW_ORDER" ]; then
     2541        ACME_NEW_ORDER=$(echo "$response" | _egrep_o 'newOrder" *: *"[^"]*"' | cut -d '"' -f 3)
     2542      fi
     2543    fi
    26402544    export ACME_NEW_ORDER
    2641 
    2642     ACME_NEW_ACCOUNT=$(echo "$response" | _egrep_o 'newAccount" *: *"[^"]*"' | cut -d '"' -f 3)
     2545    export ACME_NEW_ORDER_RES
     2546
     2547    ACME_NEW_ACCOUNT=$(echo "$response" | _egrep_o 'new-reg" *: *"[^"]*"' | cut -d '"' -f 3)
     2548    ACME_NEW_ACCOUNT_RES="new-reg"
     2549    if [ -z "$ACME_NEW_ACCOUNT" ]; then
     2550      ACME_NEW_ACCOUNT=$(echo "$response" | _egrep_o 'new-account" *: *"[^"]*"' | cut -d '"' -f 3)
     2551      ACME_NEW_ACCOUNT_RES="new-account"
     2552      if [ -z "$ACME_NEW_ACCOUNT" ]; then
     2553        ACME_NEW_ACCOUNT=$(echo "$response" | _egrep_o 'newAccount" *: *"[^"]*"' | cut -d '"' -f 3)
     2554        if [ "$ACME_NEW_ACCOUNT" ]; then
     2555          export ACME_VERSION=2
     2556        fi
     2557      fi
     2558    fi
    26432559    export ACME_NEW_ACCOUNT
    2644 
    2645     ACME_REVOKE_CERT=$(echo "$response" | _egrep_o 'revokeCert" *: *"[^"]*"' | cut -d '"' -f 3)
     2560    export ACME_NEW_ACCOUNT_RES
     2561
     2562    ACME_REVOKE_CERT=$(echo "$response" | _egrep_o 'revoke-cert" *: *"[^"]*"' | cut -d '"' -f 3)
     2563    if [ -z "$ACME_REVOKE_CERT" ]; then
     2564      ACME_REVOKE_CERT=$(echo "$response" | _egrep_o 'revokeCert" *: *"[^"]*"' | cut -d '"' -f 3)
     2565    fi
    26462566    export ACME_REVOKE_CERT
    26472567
    2648     ACME_NEW_NONCE=$(echo "$response" | _egrep_o 'newNonce" *: *"[^"]*"' | cut -d '"' -f 3)
     2568    ACME_NEW_NONCE=$(echo "$response" | _egrep_o 'new-nonce" *: *"[^"]*"' | cut -d '"' -f 3)
     2569    if [ -z "$ACME_NEW_NONCE" ]; then
     2570      ACME_NEW_NONCE=$(echo "$response" | _egrep_o 'newNonce" *: *"[^"]*"' | cut -d '"' -f 3)
     2571    fi
    26492572    export ACME_NEW_NONCE
    26502573
    2651     ACME_AGREEMENT=$(echo "$response" | _egrep_o 'termsOfService" *: *"[^"]*"' | cut -d '"' -f 3)
     2574    ACME_AGREEMENT=$(echo "$response" | _egrep_o 'terms-of-service" *: *"[^"]*"' | cut -d '"' -f 3)
     2575    if [ -z "$ACME_AGREEMENT" ]; then
     2576      ACME_AGREEMENT=$(echo "$response" | _egrep_o 'termsOfService" *: *"[^"]*"' | cut -d '"' -f 3)
     2577    fi
    26522578    export ACME_AGREEMENT
    26532579
     
    26592585    _debug "ACME_AGREEMENT" "$ACME_AGREEMENT"
    26602586    _debug "ACME_NEW_NONCE" "$ACME_NEW_NONCE"
    2661     if [ "$ACME_NEW_ACCOUNT" ] && [ "$ACME_NEW_ORDER" ]; then
    2662       return 0
    2663     fi
    2664     _info "Sleep $_sleep_retry_sec and retry."
    2665     _sleep "$_sleep_retry_sec"
    2666   done
    2667   if [ "$ACME_NEW_ACCOUNT" ] && [ "$ACME_NEW_ORDER" ]; then
    2668     return 0
    2669   fi
    2670   _err "Can not init api, for $_api_server"
    2671   return 1
     2587    _debug "ACME_VERSION" "$ACME_VERSION"
     2588
     2589  fi
    26722590}
    26732591
     
    27132631  _debug2 "_ACME_SERVER_HOST" "$_ACME_SERVER_HOST"
    27142632
    2715   _ACME_SERVER_PATH="$(echo "$ACME_DIRECTORY" | cut -d : -f 2- | tr -s / | cut -d / -f 3-)"
    2716   _debug2 "_ACME_SERVER_PATH" "$_ACME_SERVER_PATH"
    2717 
    2718   CA_DIR="$CA_HOME/$_ACME_SERVER_HOST/$_ACME_SERVER_PATH"
     2633  CA_DIR="$CA_HOME/$_ACME_SERVER_HOST"
     2634
    27192635  _DEFAULT_CA_CONF="$CA_DIR/ca.conf"
     2636
    27202637  if [ -z "$CA_CONF" ]; then
    27212638    CA_CONF="$_DEFAULT_CA_CONF"
     
    27232640  _debug3 CA_CONF "$CA_CONF"
    27242641
    2725   _OLD_CADIR="$CA_HOME/$_ACME_SERVER_HOST"
    2726   _OLD_ACCOUNT_KEY="$_OLD_CADIR/account.key"
    2727   _OLD_ACCOUNT_JSON="$_OLD_CADIR/account.json"
    2728   _OLD_CA_CONF="$_OLD_CADIR/ca.conf"
     2642  if [ -f "$CA_CONF" ]; then
     2643    . "$CA_CONF"
     2644  fi
     2645
     2646  if [ -z "$ACME_DIR" ]; then
     2647    ACME_DIR="/home/.acme"
     2648  fi
     2649
     2650  if [ -z "$APACHE_CONF_BACKUP_DIR" ]; then
     2651    APACHE_CONF_BACKUP_DIR="$LE_CONFIG_HOME"
     2652  fi
     2653
     2654  if [ -z "$USER_AGENT" ]; then
     2655    USER_AGENT="$DEFAULT_USER_AGENT"
     2656  fi
     2657
     2658  if [ -z "$HTTP_HEADER" ]; then
     2659    HTTP_HEADER="$LE_CONFIG_HOME/http.header"
     2660  fi
     2661
     2662  _OLD_ACCOUNT_KEY="$LE_WORKING_DIR/account.key"
     2663  _OLD_ACCOUNT_JSON="$LE_WORKING_DIR/account.json"
    27292664
    27302665  _DEFAULT_ACCOUNT_KEY_PATH="$CA_DIR/account.key"
     
    27322667  if [ -z "$ACCOUNT_KEY_PATH" ]; then
    27332668    ACCOUNT_KEY_PATH="$_DEFAULT_ACCOUNT_KEY_PATH"
    2734     if [ -f "$_OLD_ACCOUNT_KEY" ] && ! [ -f "$ACCOUNT_KEY_PATH" ]; then
    2735       mkdir -p "$CA_DIR"
    2736       mv "$_OLD_ACCOUNT_KEY" "$ACCOUNT_KEY_PATH"
    2737     fi
    27382669  fi
    27392670
    27402671  if [ -z "$ACCOUNT_JSON_PATH" ]; then
    27412672    ACCOUNT_JSON_PATH="$_DEFAULT_ACCOUNT_JSON_PATH"
    2742     if [ -f "$_OLD_ACCOUNT_JSON" ] && ! [ -f "$ACCOUNT_JSON_PATH" ]; then
    2743       mkdir -p "$CA_DIR"
    2744       mv "$_OLD_ACCOUNT_JSON" "$ACCOUNT_JSON_PATH"
    2745     fi
    2746   fi
    2747 
    2748   if [ -f "$_OLD_CA_CONF" ] && ! [ -f "$CA_CONF" ]; then
    2749     mkdir -p "$CA_DIR"
    2750     mv "$_OLD_CA_CONF" "$CA_CONF"
    2751   fi
    2752 
    2753   if [ -f "$CA_CONF" ]; then
    2754     . "$CA_CONF"
    2755   fi
    2756 
    2757   if [ -z "$ACME_DIR" ]; then
    2758     ACME_DIR="/home/.acme"
    2759   fi
    2760 
    2761   if [ -z "$APACHE_CONF_BACKUP_DIR" ]; then
    2762     APACHE_CONF_BACKUP_DIR="$LE_CONFIG_HOME"
    2763   fi
    2764 
    2765   if [ -z "$USER_AGENT" ]; then
    2766     USER_AGENT="$DEFAULT_USER_AGENT"
    2767   fi
    2768 
    2769   if [ -z "$HTTP_HEADER" ]; then
    2770     HTTP_HEADER="$LE_CONFIG_HOME/http.header"
    27712673  fi
    27722674
     
    31683070      for included in $(cat "$2" | tr "\t" " " | grep "^ *include *.*;" | sed "s/include //" | tr -d " ;"); do
    31693071        _debug "check included $included"
    3170         if ! _startswith "$included" "/" && _exists dirname; then
    3171           _relpath="$(dirname "$_c_file")"
    3172           _debug "_relpath" "$_relpath"
    3173           included="$_relpath/$included"
    3174         fi
    31753072        if _checkConf "$1" "$included"; then
    31763073          return 0
     
    33833280    _info "Run pre hook:'$_chk_pre_hook'"
    33843281    if ! (
    3385       export Le_Domain="$_chk_main_domain"
    3386       export Le_Alt="$_chk_alt_domains"
    33873282      cd "$DOMAIN_PATH" && eval "$_chk_pre_hook"
    33883283    ); then
     
    34463341      netprc="$(echo "$_netprc" | grep "$_checkaddr")"
    34473342      if [ -z "$netprc" ]; then
    3448         netprc="$(echo "$_netprc" | grep "$LOCAL_ANY_ADDRESS:$_checkport")"
     3343        netprc="$(echo "$_netprc" | grep "$LOCAL_ANY_ADDRESS")"
    34493344      fi
    34503345      if [ "$netprc" ]; then
     
    36033498
    36043499  mkdir -p "$CA_DIR"
     3500  if [ ! -f "$ACCOUNT_KEY_PATH" ] && [ -f "$_OLD_ACCOUNT_KEY" ]; then
     3501    _info "mv $_OLD_ACCOUNT_KEY to $ACCOUNT_KEY_PATH"
     3502    mv "$_OLD_ACCOUNT_KEY" "$ACCOUNT_KEY_PATH"
     3503  fi
     3504
     3505  if [ ! -f "$ACCOUNT_JSON_PATH" ] && [ -f "$_OLD_ACCOUNT_JSON" ]; then
     3506    _info "mv $_OLD_ACCOUNT_JSON to $ACCOUNT_JSON_PATH"
     3507    mv "$_OLD_ACCOUNT_JSON" "$ACCOUNT_JSON_PATH"
     3508  fi
    36053509
    36063510  if [ ! -f "$ACCOUNT_KEY_PATH" ]; then
     
    36263530    _savecaconf "CA_EMAIL" "$_email"
    36273531  fi
    3628 
    3629   if [ "$ACME_DIRECTORY" = "$CA_ZEROSSL" ]; then
    3630     if [ -z "$_eab_id" ] || [ -z "$_eab_hmac_key" ]; then
    3631       _info "No EAB credentials found for ZeroSSL, let's get one"
    3632       if [ -z "$_email" ]; then
    3633         _info "$(__green "$PROJECT_NAME is using ZeroSSL as default CA now.")"
    3634         _info "$(__green "Please update your account with an email address first.")"
    3635         _info "$(__green "$PROJECT_ENTRY --register-account -m my@example.com")"
    3636         _info "See: $(__green "$_ZEROSSL_WIKI")"
    3637         return 1
    3638       fi
    3639       _eabresp=$(_post "email=$_email" $_ZERO_EAB_ENDPOINT)
    3640       if [ "$?" != "0" ]; then
    3641         _debug2 "$_eabresp"
    3642         _err "Can not get EAB credentials from ZeroSSL."
    3643         return 1
    3644       fi
    3645       _secure_debug2 _eabresp "$_eabresp"
    3646       _eab_id="$(echo "$_eabresp" | tr ',}' '\n\n' | grep '"eab_kid"' | cut -d : -f 2 | tr -d '"')"
    3647       _secure_debug2 _eab_id "$_eab_id"
    3648       if [ -z "$_eab_id" ]; then
    3649         _err "Can not resolve _eab_id"
    3650         return 1
    3651       fi
    3652       _eab_hmac_key="$(echo "$_eabresp" | tr ',}' '\n\n' | grep '"eab_hmac_key"' | cut -d : -f 2 | tr -d '"')"
    3653       _secure_debug2 _eab_hmac_key "$_eab_hmac_key"
    3654       if [ -z "$_eab_hmac_key" ]; then
    3655         _err "Can not resolve _eab_hmac_key"
    3656         return 1
    3657       fi
    3658       _savecaconf CA_EAB_KEY_ID "$_eab_id"
    3659       _savecaconf CA_EAB_HMAC_KEY "$_eab_hmac_key"
    3660     fi
    3661   fi
    3662   if [ "$_eab_id" ] && [ "$_eab_hmac_key" ]; then
    3663     eab_protected="{\"alg\":\"HS256\",\"kid\":\"$_eab_id\",\"url\":\"${ACME_NEW_ACCOUNT}\"}"
    3664     _debug3 eab_protected "$eab_protected"
    3665 
    3666     eab_protected64=$(printf "%s" "$eab_protected" | _base64 | _url_replace)
    3667     _debug3 eab_protected64 "$eab_protected64"
    3668 
    3669     eab_payload64=$(printf "%s" "$jwk" | _base64 | _url_replace)
    3670     _debug3 eab_payload64 "$eab_payload64"
    3671 
    3672     eab_sign_t="$eab_protected64.$eab_payload64"
    3673     _debug3 eab_sign_t "$eab_sign_t"
    3674 
    3675     key_hex="$(_durl_replace_base64 "$_eab_hmac_key" | _dbase64 multi | _hex_dump | tr -d ' ')"
    3676     _debug3 key_hex "$key_hex"
    3677 
    3678     eab_signature=$(printf "%s" "$eab_sign_t" | _hmac sha256 $key_hex | _base64 | _url_replace)
    3679     _debug3 eab_signature "$eab_signature"
    3680 
    3681     externalBinding=",\"externalAccountBinding\":{\"protected\":\"$eab_protected64\", \"payload\":\"$eab_payload64\", \"signature\":\"$eab_signature\"}"
    3682     _debug3 externalBinding "$externalBinding"
    3683   fi
    3684   if [ "$_email" ]; then
    3685     email_sg="\"contact\": [\"mailto:$_email\"], "
    3686   fi
    3687   regjson="{$email_sg\"termsOfServiceAgreed\": true$externalBinding}"
     3532  if [ "$ACME_VERSION" = "2" ]; then
     3533    if [ "$ACME_DIRECTORY" = "$CA_ZEROSSL" ]; then
     3534      if [ -z "$_eab_id" ] || [ -z "$_eab_hmac_key" ]; then
     3535        _info "No EAB credentials found for ZeroSSL, let's get one"
     3536        if [ -z "$_email" ]; then
     3537          _err "Please provide a email address for ZeroSSL account."
     3538          _err "See ZeroSSL usage: $_ZEROSSL_WIKI"
     3539          return 1
     3540        fi
     3541        _eabresp=$(_post "email=$_email" $_ZERO_EAB_ENDPOINT)
     3542        if [ "$?" != "0" ]; then
     3543          _debug2 "$_eabresp"
     3544          _err "Can not get EAB credentials from ZeroSSL."
     3545          return 1
     3546        fi
     3547        _eab_id="$(echo "$_eabresp" | tr ',}' '\n' | grep '"eab_kid"' | cut -d : -f 2 | tr -d '"')"
     3548        if [ -z "$_eab_id" ]; then
     3549          _err "Can not resolve _eab_id"
     3550          return 1
     3551        fi
     3552        _eab_hmac_key="$(echo "$_eabresp" | tr ',}' '\n' | grep '"eab_hmac_key"' | cut -d : -f 2 | tr -d '"')"
     3553        if [ -z "$_eab_hmac_key" ]; then
     3554          _err "Can not resolve _eab_hmac_key"
     3555          return 1
     3556        fi
     3557        _savecaconf CA_EAB_KEY_ID "$_eab_id"
     3558        _savecaconf CA_EAB_HMAC_KEY "$_eab_hmac_key"
     3559      fi
     3560    fi
     3561    if [ "$_eab_id" ] && [ "$_eab_hmac_key" ]; then
     3562      eab_protected="{\"alg\":\"HS256\",\"kid\":\"$_eab_id\",\"url\":\"${ACME_NEW_ACCOUNT}\"}"
     3563      _debug3 eab_protected "$eab_protected"
     3564
     3565      eab_protected64=$(printf "%s" "$eab_protected" | _base64 | _url_replace)
     3566      _debug3 eab_protected64 "$eab_protected64"
     3567
     3568      eab_payload64=$(printf "%s" "$jwk" | _base64 | _url_replace)
     3569      _debug3 eab_payload64 "$eab_payload64"
     3570
     3571      eab_sign_t="$eab_protected64.$eab_payload64"
     3572      _debug3 eab_sign_t "$eab_sign_t"
     3573
     3574      key_hex="$(_durl_replace_base64 "$_eab_hmac_key" | _dbase64 | _hex_dump | tr -d ' ')"
     3575      _debug3 key_hex "$key_hex"
     3576
     3577      eab_signature=$(printf "%s" "$eab_sign_t" | _hmac sha256 $key_hex | _base64 | _url_replace)
     3578      _debug3 eab_signature "$eab_signature"
     3579
     3580      externalBinding=",\"externalAccountBinding\":{\"protected\":\"$eab_protected64\", \"payload\":\"$eab_payload64\", \"signature\":\"$eab_signature\"}"
     3581      _debug3 externalBinding "$externalBinding"
     3582    fi
     3583    if [ "$_email" ]; then
     3584      email_sg="\"contact\": [\"mailto:$_email\"], "
     3585    fi
     3586    regjson="{$email_sg\"termsOfServiceAgreed\": true$externalBinding}"
     3587  else
     3588    _reg_res="$ACME_NEW_ACCOUNT_RES"
     3589    regjson='{"resource": "'$_reg_res'", "terms-of-service-agreed": true, "agreement": "'$ACME_AGREEMENT'"}'
     3590    if [ "$_email" ]; then
     3591      regjson='{"resource": "'$_reg_res'", "contact": ["mailto:'$_email'"], "terms-of-service-agreed": true, "agreement": "'$ACME_AGREEMENT'"}'
     3592    fi
     3593  fi
    36883594
    36893595  _info "Registering account: $ACME_DIRECTORY"
     
    37403646  _initpath
    37413647
     3648  if [ ! -f "$ACCOUNT_KEY_PATH" ] && [ -f "$_OLD_ACCOUNT_KEY" ]; then
     3649    _info "mv $_OLD_ACCOUNT_KEY to $ACCOUNT_KEY_PATH"
     3650    mv "$_OLD_ACCOUNT_KEY" "$ACCOUNT_KEY_PATH"
     3651  fi
     3652
     3653  if [ ! -f "$ACCOUNT_JSON_PATH" ] && [ -f "$_OLD_ACCOUNT_JSON" ]; then
     3654    _info "mv $_OLD_ACCOUNT_JSON to $ACCOUNT_JSON_PATH"
     3655    mv "$_OLD_ACCOUNT_JSON" "$ACCOUNT_JSON_PATH"
     3656  fi
     3657
    37423658  if [ ! -f "$ACCOUNT_KEY_PATH" ]; then
    37433659    _err "Account key is not found at: $ACCOUNT_KEY_PATH"
     
    37603676
    37613677  _email="$(_getAccountEmail)"
    3762 
    3763   if [ "$ACCOUNT_EMAIL" ]; then
    3764     updjson='{"contact": ["mailto:'$_email'"]}'
    3765   else
    3766     updjson='{"contact": []}'
    3767   fi
    3768 
     3678  if [ "$ACME_VERSION" = "2" ]; then
     3679    if [ "$ACCOUNT_EMAIL" ]; then
     3680      updjson='{"contact": ["mailto:'$_email'"]}'
     3681    else
     3682      updjson='{"contact": []}'
     3683    fi
     3684  else
     3685    # ACMEv1: Updates happen the same way a registration is done.
     3686    # https://tools.ietf.org/html/draft-ietf-acme-acme-01#section-6.3
     3687    _regAccount
     3688    return
     3689  fi
     3690
     3691  # this part handles ACMEv2 account updates.
    37693692  _send_signed_request "$_accUri" "$updjson"
    37703693
     
    37823705  _initpath
    37833706
     3707  if [ ! -f "$ACCOUNT_KEY_PATH" ] && [ -f "$_OLD_ACCOUNT_KEY" ]; then
     3708    _info "mv $_OLD_ACCOUNT_KEY to $ACCOUNT_KEY_PATH"
     3709    mv "$_OLD_ACCOUNT_KEY" "$ACCOUNT_KEY_PATH"
     3710  fi
     3711
     3712  if [ ! -f "$ACCOUNT_JSON_PATH" ] && [ -f "$_OLD_ACCOUNT_JSON" ]; then
     3713    _info "mv $_OLD_ACCOUNT_JSON to $ACCOUNT_JSON_PATH"
     3714    mv "$_OLD_ACCOUNT_JSON" "$ACCOUNT_JSON_PATH"
     3715  fi
     3716
    37843717  if [ ! -f "$ACCOUNT_KEY_PATH" ]; then
    37853718    _err "Account key is not found at: $ACCOUNT_KEY_PATH"
     
    38013734  _initAPI
    38023735
    3803   _djson="{\"status\":\"deactivated\"}"
    3804 
     3736  if [ "$ACME_VERSION" = "2" ]; then
     3737    _djson="{\"status\":\"deactivated\"}"
     3738  else
     3739    _djson="{\"resource\": \"reg\", \"status\":\"deactivated\"}"
     3740  fi
    38053741  if _send_signed_request "$_accUri" "$_djson" && _contains "$response" '"deactivated"'; then
    38063742    _info "Deactivate account success for $_accUri."
     
    39073843  _t_vtype="$3"
    39083844  _debug2 _t_vtype "$_t_vtype"
    3909 
    3910   _send_signed_request "$_t_url" "{}"
    3911 
     3845  if [ "$ACME_VERSION" = "2" ]; then
     3846    _send_signed_request "$_t_url" "{}"
     3847  else
     3848    _send_signed_request "$_t_url" "{\"resource\": \"challenge\", \"type\": \"$_t_vtype\", \"keyAuthorization\": \"$_t_key_authz\"}"
     3849  fi
    39123850}
    39133851
     
    39523890#checks if cf server is available
    39533891_ns_is_available_cf() {
    3954   if _get "https://cloudflare-dns.com" "" 1 >/dev/null 2>&1; then
    3955     return 0
    3956   else
    3957     return 1
    3958   fi
    3959 }
    3960 
    3961 _ns_is_available_google() {
    3962   if _get "https://dns.google" "" 1 >/dev/null 2>&1; then
     3892  if _get "https://cloudflare-dns.com" >/dev/null 2>&1; then
    39633893    return 0
    39643894  else
     
    39723902  _cf_ld_type="$2"
    39733903  _cf_ep="https://dns.google/resolve"
    3974   _ns_lookup_impl "$_cf_ep" "$_cf_ld" "$_cf_ld_type"
    3975 }
    3976 
    3977 _ns_is_available_ali() {
    3978   if _get "https://dns.alidns.com" "" 1 >/dev/null 2>&1; then
    3979     return 0
    3980   else
    3981     return 1
    3982   fi
    3983 }
    3984 
    3985 #domain, type
    3986 _ns_lookup_ali() {
    3987   _cf_ld="$1"
    3988   _cf_ld_type="$2"
    3989   _cf_ep="https://dns.alidns.com/resolve"
    3990   _ns_lookup_impl "$_cf_ep" "$_cf_ld" "$_cf_ld_type"
    3991 }
    3992 
    3993 _ns_is_available_dp() {
    3994   if _get "https://doh.pub" "" 1 >/dev/null 2>&1; then
    3995     return 0
    3996   else
    3997     return 1
    3998   fi
    3999 }
    4000 
    4001 #dnspod
    4002 _ns_lookup_dp() {
    4003   _cf_ld="$1"
    4004   _cf_ld_type="$2"
    4005   _cf_ep="https://doh.pub/dns-query"
    40063904  _ns_lookup_impl "$_cf_ep" "$_cf_ld" "$_cf_ld_type"
    40073905}
     
    40143912      _debug "Use cloudflare doh server"
    40153913      export DOH_USE=$DOH_CLOUDFLARE
    4016     elif _ns_is_available_google; then
     3914    else
    40173915      _debug "Use google doh server"
    40183916      export DOH_USE=$DOH_GOOGLE
    4019     elif _ns_is_available_ali; then
    4020       _debug "Use aliyun doh server"
    4021       export DOH_USE=$DOH_ALI
    4022     elif _ns_is_available_dp; then
    4023       _debug "Use dns pod doh server"
    4024       export DOH_USE=$DOH_DP
    4025     else
    4026       _err "No doh"
    40273917    fi
    40283918  fi
     
    40303920  if [ "$DOH_USE" = "$DOH_CLOUDFLARE" ] || [ -z "$DOH_USE" ]; then
    40313921    _ns_lookup_cf "$@"
    4032   elif [ "$DOH_USE" = "$DOH_GOOGLE" ]; then
     3922  else
    40333923    _ns_lookup_google "$@"
    4034   elif [ "$DOH_USE" = "$DOH_ALI" ]; then
    4035     _ns_lookup_ali "$@"
    4036   elif [ "$DOH_USE" = "$DOH_DP" ]; then
    4037     _ns_lookup_dp "$@"
    4038   else
    4039     _err "Unknown doh provider: DOH_USE=$DOH_USE"
    40403924  fi
    40413925
     
    40623946    _ns_purge_cf "$_p_txtdomain" "TXT"
    40633947  else
    4064     _debug "no purge api for this doh api, just sleep 5 secs"
     3948    _debug "no purge api for google dns api, just sleep 5 secs"
    40653949    _sleep 5
    40663950  fi
     
    40753959
    40763960  while [ "$(_time)" -le "$_end_time" ]; do
    4077     _info "You can use '--dnssleep' to disable public dns checks."
    4078     _info "See: $_DNSCHECK_WIKI"
    40793961    _left=""
    40803962    for entry in $dns_entries; do
     
    41244006
    41254007#file
    4126 _get_chain_issuers() {
     4008_get_cert_issuers() {
    41274009  _cfile="$1"
    4128   if _contains "$(${ACME_OPENSSL_BIN:-openssl} help crl2pkcs7 2>&1)" "Usage: crl2pkcs7" || _contains "$(${ACME_OPENSSL_BIN:-openssl} crl2pkcs7 -help 2>&1)" "Usage: crl2pkcs7" || _contains "$(${ACME_OPENSSL_BIN:-openssl} crl2pkcs7 help 2>&1)" "unknown option help"; then
    4129     ${ACME_OPENSSL_BIN:-openssl} crl2pkcs7 -nocrl -certfile $_cfile | ${ACME_OPENSSL_BIN:-openssl} pkcs7 -print_certs -text -noout | grep -i 'Issuer:' | _egrep_o "CN *=[^,]*" | cut -d = -f 2
    4130   else
    4131     _cindex=1
    4132     for _startn in $(grep -n -- "$BEGIN_CERT" "$_cfile" | cut -d : -f 1); do
    4133       _endn="$(grep -n -- "$END_CERT" "$_cfile" | cut -d : -f 1 | _head_n $_cindex | _tail_n 1)"
    4134       _debug2 "_startn" "$_startn"
    4135       _debug2 "_endn" "$_endn"
    4136       if [ "$DEBUG" ]; then
    4137         _debug2 "cert$_cindex" "$(sed -n "$_startn,${_endn}p" "$_cfile")"
    4138       fi
    4139       sed -n "$_startn,${_endn}p" "$_cfile" | ${ACME_OPENSSL_BIN:-openssl} x509 -text -noout | grep 'Issuer:' | _egrep_o "CN *=[^,]*" | cut -d = -f 2 | sed "s/ *\(.*\)/\1/"
    4140       _cindex=$(_math $_cindex + 1)
    4141     done
    4142   fi
    4143 }
    4144 
    4145 #
    4146 _get_chain_subjects() {
    4147   _cfile="$1"
    4148   if _contains "$(${ACME_OPENSSL_BIN:-openssl} help crl2pkcs7 2>&1)" "Usage: crl2pkcs7" || _contains "$(${ACME_OPENSSL_BIN:-openssl} crl2pkcs7 -help 2>&1)" "Usage: crl2pkcs7" || _contains "$(${ACME_OPENSSL_BIN:-openssl} crl2pkcs7 help 2>&1)" "unknown option help"; then
    4149     ${ACME_OPENSSL_BIN:-openssl} crl2pkcs7 -nocrl -certfile $_cfile | ${ACME_OPENSSL_BIN:-openssl} pkcs7 -print_certs -text -noout | grep -i 'Subject:' | _egrep_o "CN *=[^,]*" | cut -d = -f 2
    4150   else
    4151     _cindex=1
    4152     for _startn in $(grep -n -- "$BEGIN_CERT" "$_cfile" | cut -d : -f 1); do
    4153       _endn="$(grep -n -- "$END_CERT" "$_cfile" | cut -d : -f 1 | _head_n $_cindex | _tail_n 1)"
    4154       _debug2 "_startn" "$_startn"
    4155       _debug2 "_endn" "$_endn"
    4156       if [ "$DEBUG" ]; then
    4157         _debug2 "cert$_cindex" "$(sed -n "$_startn,${_endn}p" "$_cfile")"
    4158       fi
    4159       sed -n "$_startn,${_endn}p" "$_cfile" | ${ACME_OPENSSL_BIN:-openssl} x509 -text -noout | grep -i 'Subject:' | _egrep_o "CN *=[^,]*" | cut -d = -f 2 | sed "s/ *\(.*\)/\1/"
    4160       _cindex=$(_math $_cindex + 1)
    4161     done
     4010  if _contains "$(${ACME_OPENSSL_BIN:-openssl} help crl2pkcs7 2>&1)" "Usage: crl2pkcs7" || _contains "$(${ACME_OPENSSL_BIN:-openssl} crl2pkcs7 help 2>&1)" "unknown option help"; then
     4011    ${ACME_OPENSSL_BIN:-openssl} crl2pkcs7 -nocrl -certfile $_cfile | ${ACME_OPENSSL_BIN:-openssl} pkcs7 -print_certs -text -noout | grep 'Issuer:' | _egrep_o "CN *=[^,]*" | cut -d = -f 2
     4012  else
     4013    ${ACME_OPENSSL_BIN:-openssl} x509 -in $_cfile -text -noout | grep 'Issuer:' | _egrep_o "CN *=[^,]*" | cut -d = -f 2
    41624014  fi
    41634015}
     
    41674019  _cfile="$1"
    41684020  _missuer="$2"
    4169   _fissuers="$(_get_chain_issuers $_cfile)"
     4021  _fissuers="$(_get_cert_issuers $_cfile)"
    41704022  _debug2 _fissuers "$_fissuers"
    4171   _rootissuer="$(echo "$_fissuers" | _lower_case | _tail_n 1)"
    4172   _debug2 _rootissuer "$_rootissuer"
     4023  if _contains "$_fissuers" "$_missuer"; then
     4024    return 0
     4025  fi
     4026  _fissuers="$(echo "$_fissuers" | _lower_case)"
    41734027  _missuer="$(echo "$_missuer" | _lower_case)"
    4174   _contains "$_rootissuer" "$_missuer"
     4028  _contains "$_fissuers" "$_missuer"
    41754029}
    41764030
     
    42124066    _initpath "$_main_domain" "$_key_length"
    42134067    mkdir -p "$DOMAIN_PATH"
    4214   elif ! _hasfield "$_web_roots" "$W_DNS"; then
    4215     Le_OrderFinalize=""
    4216     Le_LinkOrder=""
    4217     Le_LinkCert=""
    42184068  fi
    42194069
     
    42254075  _debug "Using ACME_DIRECTORY: $ACME_DIRECTORY"
    42264076
    4227   if ! _initAPI; then
    4228     return 1
    4229   fi
     4077  _initAPI
    42304078
    42314079  if [ -f "$DOMAIN_CONF" ]; then
     
    43314179  dvsep=','
    43324180  if [ -z "$vlist" ]; then
    4333     #make new order request
    4334     _identifiers="{\"type\":\"dns\",\"value\":\"$(_idn "$_main_domain")\"}"
    4335     _w_index=1
    4336     while true; do
    4337       d="$(echo "$_alt_domains," | cut -d , -f "$_w_index")"
    4338       _w_index="$(_math "$_w_index" + 1)"
    4339       _debug d "$d"
    4340       if [ -z "$d" ]; then
    4341         break
    4342       fi
    4343       _identifiers="$_identifiers,{\"type\":\"dns\",\"value\":\"$(_idn "$d")\"}"
    4344     done
    4345     _debug2 _identifiers "$_identifiers"
    4346     if ! _send_signed_request "$ACME_NEW_ORDER" "{\"identifiers\": [$_identifiers]}"; then
    4347       _err "Create new order error."
    4348       _clearup
    4349       _on_issue_err "$_post_hook"
    4350       return 1
    4351     fi
    4352     Le_LinkOrder="$(echo "$responseHeaders" | grep -i '^Location.*$' | _tail_n 1 | tr -d "\r\n " | cut -d ":" -f 2-)"
    4353     _debug Le_LinkOrder "$Le_LinkOrder"
    4354     Le_OrderFinalize="$(echo "$response" | _egrep_o '"finalize" *: *"[^"]*"' | cut -d '"' -f 4)"
    4355     _debug Le_OrderFinalize "$Le_OrderFinalize"
    4356     if [ -z "$Le_OrderFinalize" ]; then
    4357       _err "Create new order error. Le_OrderFinalize not found. $response"
    4358       _clearup
    4359       _on_issue_err "$_post_hook"
    4360       return 1
    4361     fi
    4362 
    4363     #for dns manual mode
    4364     _savedomainconf "Le_OrderFinalize" "$Le_OrderFinalize"
    4365 
    4366     _authorizations_seg="$(echo "$response" | _json_decode | _egrep_o '"authorizations" *: *\[[^\[]*\]' | cut -d '[' -f 2 | tr -d ']' | tr -d '"')"
    4367     _debug2 _authorizations_seg "$_authorizations_seg"
    4368     if [ -z "$_authorizations_seg" ]; then
    4369       _err "_authorizations_seg not found."
    4370       _clearup
    4371       _on_issue_err "$_post_hook"
    4372       return 1
    4373     fi
    4374 
    4375     #domain and authz map
    4376     _authorizations_map=""
    4377     for _authz_url in $(echo "$_authorizations_seg" | tr ',' ' '); do
    4378       _debug2 "_authz_url" "$_authz_url"
    4379       if ! _send_signed_request "$_authz_url"; then
    4380         _err "get to authz error."
    4381         _err "_authorizations_seg" "$_authorizations_seg"
    4382         _err "_authz_url" "$_authz_url"
     4181    if [ "$ACME_VERSION" = "2" ]; then
     4182      #make new order request
     4183      _identifiers="{\"type\":\"dns\",\"value\":\"$(_idn "$_main_domain")\"}"
     4184      _w_index=1
     4185      while true; do
     4186        d="$(echo "$_alt_domains," | cut -d , -f "$_w_index")"
     4187        _w_index="$(_math "$_w_index" + 1)"
     4188        _debug d "$d"
     4189        if [ -z "$d" ]; then
     4190          break
     4191        fi
     4192        _identifiers="$_identifiers,{\"type\":\"dns\",\"value\":\"$(_idn "$d")\"}"
     4193      done
     4194      _debug2 _identifiers "$_identifiers"
     4195      if ! _send_signed_request "$ACME_NEW_ORDER" "{\"identifiers\": [$_identifiers]}"; then
     4196        _err "Create new order error."
    43834197        _clearup
    43844198        _on_issue_err "$_post_hook"
    43854199        return 1
    43864200      fi
    4387 
    4388       response="$(echo "$response" | _normalizeJson)"
    4389       _debug2 response "$response"
    4390       _d="$(echo "$response" | _egrep_o '"value" *: *"[^"]*"' | cut -d : -f 2 | tr -d ' "')"
    4391       if _contains "$response" "\"wildcard\" *: *true"; then
    4392         _d="*.$_d"
    4393       fi
    4394       _debug2 _d "$_d"
    4395       _authorizations_map="$_d,$response
     4201      Le_LinkOrder="$(echo "$responseHeaders" | grep -i '^Location.*$' | _tail_n 1 | tr -d "\r\n " | cut -d ":" -f 2-)"
     4202      _debug Le_LinkOrder "$Le_LinkOrder"
     4203      Le_OrderFinalize="$(echo "$response" | _egrep_o '"finalize" *: *"[^"]*"' | cut -d '"' -f 4)"
     4204      _debug Le_OrderFinalize "$Le_OrderFinalize"
     4205      if [ -z "$Le_OrderFinalize" ]; then
     4206        _err "Create new order error. Le_OrderFinalize not found. $response"
     4207        _clearup
     4208        _on_issue_err "$_post_hook"
     4209        return 1
     4210      fi
     4211
     4212      #for dns manual mode
     4213      _savedomainconf "Le_OrderFinalize" "$Le_OrderFinalize"
     4214
     4215      _authorizations_seg="$(echo "$response" | _json_decode | _egrep_o '"authorizations" *: *\[[^\[]*\]' | cut -d '[' -f 2 | tr -d ']' | tr -d '"')"
     4216      _debug2 _authorizations_seg "$_authorizations_seg"
     4217      if [ -z "$_authorizations_seg" ]; then
     4218        _err "_authorizations_seg not found."
     4219        _clearup
     4220        _on_issue_err "$_post_hook"
     4221        return 1
     4222      fi
     4223
     4224      #domain and authz map
     4225      _authorizations_map=""
     4226      for _authz_url in $(echo "$_authorizations_seg" | tr ',' ' '); do
     4227        _debug2 "_authz_url" "$_authz_url"
     4228        if ! _send_signed_request "$_authz_url"; then
     4229          _err "get to authz error."
     4230          _err "_authorizations_seg" "$_authorizations_seg"
     4231          _err "_authz_url" "$_authz_url"
     4232          _clearup
     4233          _on_issue_err "$_post_hook"
     4234          return 1
     4235        fi
     4236
     4237        response="$(echo "$response" | _normalizeJson)"
     4238        _debug2 response "$response"
     4239        _d="$(echo "$response" | _egrep_o '"value" *: *"[^"]*"' | cut -d : -f 2 | tr -d ' "')"
     4240        if _contains "$response" "\"wildcard\" *: *true"; then
     4241          _d="*.$_d"
     4242        fi
     4243        _debug2 _d "$_d"
     4244        _authorizations_map="$_d,$response
    43964245$_authorizations_map"
    4397     done
    4398     _debug2 _authorizations_map "$_authorizations_map"
     4246      done
     4247      _debug2 _authorizations_map "$_authorizations_map"
     4248    fi
    43994249
    44004250    _index=0
     
    44274277      fi
    44284278
    4429       _idn_d="$(_idn "$d")"
    4430       _candidates="$(echo "$_authorizations_map" | grep -i "^$_idn_d,")"
    4431       _debug2 _candidates "$_candidates"
    4432       if [ "$(echo "$_candidates" | wc -l)" -gt 1 ]; then
    4433         for _can in $_candidates; do
    4434           if _startswith "$(echo "$_can" | tr '.' '|')" "$(echo "$_idn_d" | tr '.' '|'),"; then
    4435             _candidates="$_can"
    4436             break
    4437           fi
    4438         done
    4439       fi
    4440       response="$(echo "$_candidates" | sed "s/$_idn_d,//")"
    4441       _debug2 "response" "$response"
    4442       if [ -z "$response" ]; then
    4443         _err "get to authz error."
    4444         _err "_authorizations_map" "$_authorizations_map"
    4445         _clearup
    4446         _on_issue_err "$_post_hook"
    4447         return 1
     4279      if [ "$ACME_VERSION" = "2" ]; then
     4280        _idn_d="$(_idn "$d")"
     4281        _candidates="$(echo "$_authorizations_map" | grep -i "^$_idn_d,")"
     4282        _debug2 _candidates "$_candidates"
     4283        if [ "$(echo "$_candidates" | wc -l)" -gt 1 ]; then
     4284          for _can in $_candidates; do
     4285            if _startswith "$(echo "$_can" | tr '.' '|')" "$(echo "$_idn_d" | tr '.' '|'),"; then
     4286              _candidates="$_can"
     4287              break
     4288            fi
     4289          done
     4290        fi
     4291        response="$(echo "$_candidates" | sed "s/$_idn_d,//")"
     4292        _debug2 "response" "$response"
     4293        if [ -z "$response" ]; then
     4294          _err "get to authz error."
     4295          _err "_authorizations_map" "$_authorizations_map"
     4296          _clearup
     4297          _on_issue_err "$_post_hook"
     4298          return 1
     4299        fi
     4300      else
     4301        if ! __get_domain_new_authz "$d"; then
     4302          _clearup
     4303          _on_issue_err "$_post_hook"
     4304          return 1
     4305        fi
    44484306      fi
    44494307
     
    44864344          return 1
    44874345        fi
    4488 
    4489         uri="$(echo "$entry" | _egrep_o '"url":"[^"]*' | cut -d '"' -f 4 | _head_n 1)"
    4490 
     4346        if [ "$ACME_VERSION" = "2" ]; then
     4347          uri="$(echo "$entry" | _egrep_o '"url":"[^"]*' | cut -d '"' -f 4 | _head_n 1)"
     4348        else
     4349          uri="$(echo "$entry" | _egrep_o '"uri":"[^"]*' | cut -d '"' -f 4)"
     4350        fi
    44914351        _debug uri "$uri"
    44924352
     
    47834643      fi
    47844644
     4645      _debug "sleep 2 secs to verify"
     4646      sleep 2
     4647      _debug "checking"
     4648      if [ "$ACME_VERSION" = "2" ]; then
     4649        _send_signed_request "$uri"
     4650      else
     4651        response="$(_get "$uri")"
     4652      fi
     4653      if [ "$?" != "0" ]; then
     4654        _err "$d:Verify error:$response"
     4655        _clearupwebbroot "$_currentRoot" "$removelevel" "$token"
     4656        _clearup
     4657        _on_issue_err "$_post_hook" "$vlist"
     4658        return 1
     4659      fi
    47854660      _debug2 original "$response"
    47864661
     
    47894664
    47904665      status=$(echo "$response" | _egrep_o '"status":"[^"]*' | cut -d : -f 2 | tr -d '"')
    4791       _debug2 status "$status"
    4792       if _contains "$status" "invalid"; then
     4666      if [ "$status" = "valid" ]; then
     4667        _info "$(__green Success)"
     4668        _stopserver "$serverproc"
     4669        serverproc=""
     4670        _clearupwebbroot "$_currentRoot" "$removelevel" "$token"
     4671        break
     4672      fi
     4673
     4674      if [ "$status" = "invalid" ]; then
    47934675        error="$(echo "$response" | _egrep_o '"error":\{[^\}]*')"
    47944676        _debug2 error "$error"
     
    48124694      fi
    48134695
    4814       if _contains "$status" "valid"; then
    4815         _info "$(__green Success)"
    4816         _stopserver "$serverproc"
    4817         serverproc=""
    4818         _clearupwebbroot "$_currentRoot" "$removelevel" "$token"
    4819         break
    4820       fi
    4821 
    48224696      if [ "$status" = "pending" ]; then
    4823         _info "Pending, The CA is processing your order, please just wait. ($waittimes/$MAX_RETRY_TIMES)"
     4697        _info "Pending"
    48244698      elif [ "$status" = "processing" ]; then
    4825         _info "Processing, The CA is processing your order, please just wait. ($waittimes/$MAX_RETRY_TIMES)"
     4699        _info "Processing"
    48264700      else
    48274701        _err "$d:Verify error:$response"
     
    48314705        return 1
    48324706      fi
    4833       _debug "sleep 2 secs to verify again"
    4834       sleep 2
    4835       _debug "checking"
    4836 
    4837       _send_signed_request "$uri"
    4838 
    4839       if [ "$?" != "0" ]; then
    4840         _err "$d:Verify error:$response"
    4841         _clearupwebbroot "$_currentRoot" "$removelevel" "$token"
    4842         _clearup
    4843         _on_issue_err "$_post_hook" "$vlist"
    4844         return 1
    4845       fi
     4707
    48464708    done
    48474709
     
    48524714  der="$(_getfile "${CSR_PATH}" "${BEGIN_CSR}" "${END_CSR}" | tr -d "\r\n" | _url_replace)"
    48534715
    4854   _info "Lets finalize the order."
    4855   _info "Le_OrderFinalize" "$Le_OrderFinalize"
    4856   if ! _send_signed_request "${Le_OrderFinalize}" "{\"csr\": \"$der\"}"; then
    4857     _err "Sign failed."
    4858     _on_issue_err "$_post_hook"
    4859     return 1
    4860   fi
    4861   if [ "$code" != "200" ]; then
    4862     _err "Sign failed, finalize code is not 200."
    4863     _err "$response"
    4864     _on_issue_err "$_post_hook"
    4865     return 1
    4866   fi
    4867   if [ -z "$Le_LinkOrder" ]; then
    4868     Le_LinkOrder="$(echo "$responseHeaders" | grep -i '^Location.*$' | _tail_n 1 | tr -d "\r\n \t" | cut -d ":" -f 2-)"
    4869   fi
    4870 
    4871   _savedomainconf "Le_LinkOrder" "$Le_LinkOrder"
    4872 
    4873   _link_cert_retry=0
    4874   _MAX_CERT_RETRY=30
    4875   while [ "$_link_cert_retry" -lt "$_MAX_CERT_RETRY" ]; do
    4876     if _contains "$response" "\"status\":\"valid\""; then
    4877       _debug "Order status is valid."
    4878       Le_LinkCert="$(echo "$response" | _egrep_o '"certificate" *: *"[^"]*"' | cut -d '"' -f 4)"
    4879       _debug Le_LinkCert "$Le_LinkCert"
    4880       if [ -z "$Le_LinkCert" ]; then
    4881         _err "Sign error, can not find Le_LinkCert"
     4716  if [ "$ACME_VERSION" = "2" ]; then
     4717    _info "Lets finalize the order."
     4718    _info "Le_OrderFinalize" "$Le_OrderFinalize"
     4719    if ! _send_signed_request "${Le_OrderFinalize}" "{\"csr\": \"$der\"}"; then
     4720      _err "Sign failed."
     4721      _on_issue_err "$_post_hook"
     4722      return 1
     4723    fi
     4724    if [ "$code" != "200" ]; then
     4725      _err "Sign failed, finalize code is not 200."
     4726      _err "$response"
     4727      _on_issue_err "$_post_hook"
     4728      return 1
     4729    fi
     4730    if [ -z "$Le_LinkOrder" ]; then
     4731      Le_LinkOrder="$(echo "$responseHeaders" | grep -i '^Location.*$' | _tail_n 1 | tr -d "\r\n \t" | cut -d ":" -f 2-)"
     4732    fi
     4733
     4734    _savedomainconf "Le_LinkOrder" "$Le_LinkOrder"
     4735
     4736    _link_cert_retry=0
     4737    _MAX_CERT_RETRY=30
     4738    while [ "$_link_cert_retry" -lt "$_MAX_CERT_RETRY" ]; do
     4739      if _contains "$response" "\"status\":\"valid\""; then
     4740        _debug "Order status is valid."
     4741        Le_LinkCert="$(echo "$response" | _egrep_o '"certificate" *: *"[^"]*"' | cut -d '"' -f 4)"
     4742        _debug Le_LinkCert "$Le_LinkCert"
     4743        if [ -z "$Le_LinkCert" ]; then
     4744          _err "Sign error, can not find Le_LinkCert"
     4745          _err "$response"
     4746          _on_issue_err "$_post_hook"
     4747          return 1
     4748        fi
     4749        break
     4750      elif _contains "$response" "\"processing\""; then
     4751        _info "Order status is processing, lets sleep and retry."
     4752        _retryafter=$(echo "$responseHeaders" | grep -i "^Retry-After *:" | cut -d : -f 2 | tr -d ' ' | tr -d '\r')
     4753        _debug "_retryafter" "$_retryafter"
     4754        if [ "$_retryafter" ]; then
     4755          _info "Retry after: $_retryafter"
     4756          _sleep $_retryafter
     4757        else
     4758          _sleep 2
     4759        fi
     4760      else
     4761        _err "Sign error, wrong status"
    48824762        _err "$response"
    48834763        _on_issue_err "$_post_hook"
    48844764        return 1
    48854765      fi
    4886       break
    4887     elif _contains "$response" "\"processing\""; then
    4888       _info "Order status is processing, lets sleep and retry."
    4889       _retryafter=$(echo "$responseHeaders" | grep -i "^Retry-After *:" | cut -d : -f 2 | tr -d ' ' | tr -d '\r')
    4890       _debug "_retryafter" "$_retryafter"
    4891       if [ "$_retryafter" ]; then
    4892         _info "Retry after: $_retryafter"
    4893         _sleep $_retryafter
    4894       else
    4895         _sleep 2
    4896       fi
    4897     else
    4898       _err "Sign error, wrong status"
     4766      #the order is processing, so we are going to poll order status
     4767      if [ -z "$Le_LinkOrder" ]; then
     4768        _err "Sign error, can not get order link location header"
     4769        _err "responseHeaders" "$responseHeaders"
     4770        _on_issue_err "$_post_hook"
     4771        return 1
     4772      fi
     4773      _info "Polling order status: $Le_LinkOrder"
     4774      if ! _send_signed_request "$Le_LinkOrder"; then
     4775        _err "Sign failed, can not post to Le_LinkOrder cert:$Le_LinkOrder."
     4776        _err "$response"
     4777        _on_issue_err "$_post_hook"
     4778        return 1
     4779      fi
     4780      _link_cert_retry="$(_math $_link_cert_retry + 1)"
     4781    done
     4782
     4783    if [ -z "$Le_LinkCert" ]; then
     4784      _err "Sign failed, can not get Le_LinkCert, retry time limit."
    48994785      _err "$response"
    49004786      _on_issue_err "$_post_hook"
    49014787      return 1
    49024788    fi
    4903     #the order is processing, so we are going to poll order status
    4904     if [ -z "$Le_LinkOrder" ]; then
    4905       _err "Sign error, can not get order link location header"
    4906       _err "responseHeaders" "$responseHeaders"
    4907       _on_issue_err "$_post_hook"
    4908       return 1
    4909     fi
    4910     _info "Polling order status: $Le_LinkOrder"
    4911     if ! _send_signed_request "$Le_LinkOrder"; then
    4912       _err "Sign failed, can not post to Le_LinkOrder cert:$Le_LinkOrder."
     4789    _info "Downloading cert."
     4790    _info "Le_LinkCert" "$Le_LinkCert"
     4791    if ! _send_signed_request "$Le_LinkCert"; then
     4792      _err "Sign failed, can not download cert:$Le_LinkCert."
    49134793      _err "$response"
    49144794      _on_issue_err "$_post_hook"
    49154795      return 1
    49164796    fi
    4917     _link_cert_retry="$(_math $_link_cert_retry + 1)"
    4918   done
    4919 
    4920   if [ -z "$Le_LinkCert" ]; then
    4921     _err "Sign failed, can not get Le_LinkCert, retry time limit."
    4922     _err "$response"
    4923     _on_issue_err "$_post_hook"
    4924     return 1
    4925   fi
    4926   _info "Downloading cert."
    4927   _info "Le_LinkCert" "$Le_LinkCert"
    4928   if ! _send_signed_request "$Le_LinkCert"; then
    4929     _err "Sign failed, can not download cert:$Le_LinkCert."
    4930     _err "$response"
    4931     _on_issue_err "$_post_hook"
    4932     return 1
    4933   fi
    4934 
    4935   echo "$response" >"$CERT_PATH"
    4936   _split_cert_chain "$CERT_PATH" "$CERT_FULLCHAIN_PATH" "$CA_CERT_PATH"
    4937   if [ -z "$_preferred_chain" ]; then
    4938     _preferred_chain=$(_readcaconf DEFAULT_PREFERRED_CHAIN)
    4939   fi
    4940   if [ "$_preferred_chain" ] && [ -f "$CERT_FULLCHAIN_PATH" ]; then
    4941     if [ "$DEBUG" ]; then
    4942       _debug "default chain issuers: " "$(_get_chain_issuers "$CERT_FULLCHAIN_PATH")"
    4943     fi
    4944     if ! _match_issuer "$CERT_FULLCHAIN_PATH" "$_preferred_chain"; then
    4945       rels="$(echo "$responseHeaders" | tr -d ' <>' | grep -i "^link:" | grep -i 'rel="alternate"' | cut -d : -f 2- | cut -d ';' -f 1)"
    4946       _debug2 "rels" "$rels"
    4947       for rel in $rels; do
    4948         _info "Try rel: $rel"
    4949         if ! _send_signed_request "$rel"; then
    4950           _err "Sign failed, can not download cert:$rel"
    4951           _err "$response"
    4952           continue
    4953         fi
    4954         _relcert="$CERT_PATH.alt"
    4955         _relfullchain="$CERT_FULLCHAIN_PATH.alt"
    4956         _relca="$CA_CERT_PATH.alt"
    4957         echo "$response" >"$_relcert"
    4958         _split_cert_chain "$_relcert" "$_relfullchain" "$_relca"
    4959         if [ "$DEBUG" ]; then
    4960           _debug "rel chain issuers: " "$(_get_chain_issuers "$_relfullchain")"
    4961         fi
    4962         if _match_issuer "$_relfullchain" "$_preferred_chain"; then
    4963           _info "Matched issuer in: $rel"
    4964           cat $_relcert >"$CERT_PATH"
    4965           cat $_relfullchain >"$CERT_FULLCHAIN_PATH"
    4966           cat $_relca >"$CA_CERT_PATH"
    4967           rm -f "$_relcert"
    4968           rm -f "$_relfullchain"
    4969           rm -f "$_relca"
    4970           break
    4971         fi
    4972         rm -f "$_relcert"
    4973         rm -f "$_relfullchain"
    4974         rm -f "$_relca"
    4975       done
    4976     fi
     4797
     4798    echo "$response" >"$CERT_PATH"
     4799    _split_cert_chain "$CERT_PATH" "$CERT_FULLCHAIN_PATH" "$CA_CERT_PATH"
     4800
     4801    if [ "$_preferred_chain" ] && [ -f "$CERT_FULLCHAIN_PATH" ]; then
     4802      if ! _match_issuer "$CERT_FULLCHAIN_PATH" "$_preferred_chain"; then
     4803        rels="$(echo "$responseHeaders" | tr -d ' <>' | grep -i "^link:" | grep -i 'rel="alternate"' | cut -d : -f 2- | cut -d ';' -f 1)"
     4804        _debug2 "rels" "$rels"
     4805        for rel in $rels; do
     4806          _info "Try rel: $rel"
     4807          if ! _send_signed_request "$rel"; then
     4808            _err "Sign failed, can not download cert:$rel"
     4809            _err "$response"
     4810            continue
     4811          fi
     4812          _relcert="$CERT_PATH.alt"
     4813          _relfullchain="$CERT_FULLCHAIN_PATH.alt"
     4814          _relca="$CA_CERT_PATH.alt"
     4815          echo "$response" >"$_relcert"
     4816          _split_cert_chain "$_relcert" "$_relfullchain" "$_relca"
     4817          if _match_issuer "$_relfullchain" "$_preferred_chain"; then
     4818            _info "Matched issuer in: $rel"
     4819            cat $_relcert >"$CERT_PATH"
     4820            cat $_relfullchain >"$CERT_FULLCHAIN_PATH"
     4821            cat $_relca >"$CA_CERT_PATH"
     4822            break
     4823          fi
     4824        done
     4825      fi
     4826    fi
     4827  else
     4828    if ! _send_signed_request "${ACME_NEW_ORDER}" "{\"resource\": \"$ACME_NEW_ORDER_RES\", \"csr\": \"$der\"}" "needbase64"; then
     4829      _err "Sign failed. $response"
     4830      _on_issue_err "$_post_hook"
     4831      return 1
     4832    fi
     4833    _rcert="$response"
     4834    Le_LinkCert="$(grep -i '^Location.*$' "$HTTP_HEADER" | _tail_n 1 | tr -d "\r\n" | cut -d " " -f 2)"
     4835    echo "$BEGIN_CERT" >"$CERT_PATH"
     4836
     4837    #if ! _get "$Le_LinkCert" | _base64 "multiline"  >> "$CERT_PATH" ; then
     4838    #  _debug "Get cert failed. Let's try last response."
     4839    #  printf -- "%s" "$_rcert" | _dbase64 "multiline" | _base64 "multiline" >> "$CERT_PATH"
     4840    #fi
     4841
     4842    if ! printf -- "%s" "$_rcert" | _dbase64 "multiline" | _base64 "multiline" >>"$CERT_PATH"; then
     4843      _debug "Try cert link."
     4844      _get "$Le_LinkCert" | _base64 "multiline" >>"$CERT_PATH"
     4845    fi
     4846
     4847    echo "$END_CERT" >>"$CERT_PATH"
    49774848  fi
    49784849
     
    49914862    cat "$CERT_PATH"
    49924863
    4993     _info "Your cert is in: $(__green "$CERT_PATH")"
     4864    _info "Your cert is in $(__green " $CERT_PATH ")"
    49944865
    49954866    if [ -f "$CERT_KEY_PATH" ]; then
    4996       _info "Your cert key is in: $(__green "$CERT_KEY_PATH")"
     4867      _info "Your cert key is in $(__green " $CERT_KEY_PATH ")"
    49974868    fi
    49984869
     
    50034874  fi
    50044875
    5005   [ -f "$CA_CERT_PATH" ] && _info "The intermediate CA cert is in: $(__green "$CA_CERT_PATH")"
    5006   [ -f "$CERT_FULLCHAIN_PATH" ] && _info "And the full chain certs is there: $(__green "$CERT_FULLCHAIN_PATH")"
     4876  if [ "$ACME_VERSION" = "2" ]; then
     4877    _debug "v2 chain."
     4878  else
     4879    cp "$CERT_PATH" "$CERT_FULLCHAIN_PATH"
     4880    Le_LinkIssuer=$(grep -i '^Link' "$HTTP_HEADER" | _head_n 1 | cut -d " " -f 2 | cut -d ';' -f 1 | tr -d '<>')
     4881
     4882    if [ "$Le_LinkIssuer" ]; then
     4883      if ! _contains "$Le_LinkIssuer" ":"; then
     4884        _info "$(__red "Relative issuer link found.")"
     4885        Le_LinkIssuer="$_ACME_SERVER_HOST$Le_LinkIssuer"
     4886      fi
     4887      _debug Le_LinkIssuer "$Le_LinkIssuer"
     4888      _savedomainconf "Le_LinkIssuer" "$Le_LinkIssuer"
     4889
     4890      _link_issuer_retry=0
     4891      _MAX_ISSUER_RETRY=5
     4892      while [ "$_link_issuer_retry" -lt "$_MAX_ISSUER_RETRY" ]; do
     4893        _debug _link_issuer_retry "$_link_issuer_retry"
     4894        if [ "$ACME_VERSION" = "2" ]; then
     4895          if _send_signed_request "$Le_LinkIssuer"; then
     4896            echo "$response" >"$CA_CERT_PATH"
     4897            break
     4898          fi
     4899        else
     4900          if _get "$Le_LinkIssuer" >"$CA_CERT_PATH.der"; then
     4901            echo "$BEGIN_CERT" >"$CA_CERT_PATH"
     4902            _base64 "multiline" <"$CA_CERT_PATH.der" >>"$CA_CERT_PATH"
     4903            echo "$END_CERT" >>"$CA_CERT_PATH"
     4904            if ! _checkcert "$CA_CERT_PATH"; then
     4905              _err "Can not get the ca cert."
     4906              break
     4907            fi
     4908            cat "$CA_CERT_PATH" >>"$CERT_FULLCHAIN_PATH"
     4909            rm -f "$CA_CERT_PATH.der"
     4910            break
     4911          fi
     4912        fi
     4913        _link_issuer_retry=$(_math $_link_issuer_retry + 1)
     4914        _sleep "$_link_issuer_retry"
     4915      done
     4916      if [ "$_link_issuer_retry" = "$_MAX_ISSUER_RETRY" ]; then
     4917        _err "Max retry for issuer ca cert is reached."
     4918      fi
     4919    else
     4920      _debug "No Le_LinkIssuer header found."
     4921    fi
     4922  fi
     4923  [ -f "$CA_CERT_PATH" ] && _info "The intermediate CA cert is in $(__green " $CA_CERT_PATH ")"
     4924  [ -f "$CERT_FULLCHAIN_PATH" ] && _info "And the full chain certs is there: $(__green " $CERT_FULLCHAIN_PATH ")"
    50074925
    50084926  Le_CertCreateTime=$(_time)
     
    51155033  . "$DOMAIN_CONF"
    51165034  _debug Le_API "$Le_API"
    5117   if [ -z "$Le_API" ] || [ "$CA_LETSENCRYPT_V1" = "$Le_API" ]; then
    5118     #if this is from an old version, Le_API is empty,
    5119     #so, we force to use letsencrypt server
    5120     Le_API="$CA_LETSENCRYPT_V2"
     5035
     5036  if [ "$Le_API" = "$LETSENCRYPT_CA_V1" ]; then
     5037    _cleardomainconf Le_API
     5038    Le_API="$DEFAULT_CA"
     5039  fi
     5040  if [ "$Le_API" = "$LETSENCRYPT_STAGING_CA_V1" ]; then
     5041    _cleardomainconf Le_API
     5042    Le_API="$DEFAULT_STAGING_CA"
    51215043  fi
    51225044
    51235045  if [ "$Le_API" ]; then
    5124     if [ "$Le_API" != "$ACME_DIRECTORY" ]; then
    5125       _clearAPI
    5126     fi
    51275046    export ACME_DIRECTORY="$Le_API"
    51285047    #reload ca configs
     
    51325051    _debug3 "initpath again."
    51335052    _initpath "$Le_Domain" "$_isEcc"
    5134     _initAPI
    51355053  fi
    51365054
     
    53015219  _local_addr="${11}"
    53025220  _challenge_alias="${12}"
    5303   _preferred_chain="${13}"
    53045221
    53055222  _csrsubj=$(_readSubjectFromCSR "$_csrfile")
     
    53395256  fi
    53405257
     5258  if [ -z "$ACME_VERSION" ] && _contains "$_csrsubj,$_csrdomainlist" "*."; then
     5259    export ACME_VERSION=2
     5260  fi
    53415261  _initpath "$_csrsubj" "$_csrkeylength"
    53425262  mkdir -p "$DOMAIN_PATH"
     
    53455265  cp "$_csrfile" "$CSR_PATH"
    53465266
    5347   issue "$_csrW" "$_csrsubj" "$_csrdomainlist" "$_csrkeylength" "$_real_cert" "$_real_key" "$_real_ca" "$_reload_cmd" "$_real_fullchain" "$_pre_hook" "$_post_hook" "$_renew_hook" "$_local_addr" "$_challenge_alias" "$_preferred_chain"
     5267  issue "$_csrW" "$_csrsubj" "$_csrdomainlist" "$_csrkeylength" "$_real_cert" "$_real_key" "$_real_ca" "$_reload_cmd" "$_real_fullchain" "$_pre_hook" "$_post_hook" "$_renew_hook" "$_local_addr" "$_challenge_alias"
    53485268
    53495269}
     
    55485468
    55495469  if [ "$_real_cert" ]; then
    5550     _info "Installing cert to: $_real_cert"
     5470    _info "Installing cert to:$_real_cert"
    55515471    if [ -f "$_real_cert" ] && [ ! "$_ACME_IS_RENEW" ]; then
    55525472      cp "$_real_cert" "$_backup_path/cert.bak"
     
    55565476
    55575477  if [ "$_real_ca" ]; then
    5558     _info "Installing CA to: $_real_ca"
     5478    _info "Installing CA to:$_real_ca"
    55595479    if [ "$_real_ca" = "$_real_cert" ]; then
    55605480      echo "" >>"$_real_ca"
     
    55695489
    55705490  if [ "$_real_key" ]; then
    5571     _info "Installing key to: $_real_key"
     5491    _info "Installing key to:$_real_key"
    55725492    if [ -f "$_real_key" ] && [ ! "$_ACME_IS_RENEW" ]; then
    55735493      cp "$_real_key" "$_backup_path/key.bak"
     
    55825502
    55835503  if [ "$_real_fullchain" ]; then
    5584     _info "Installing full chain to: $_real_fullchain"
     5504    _info "Installing full chain to:$_real_fullchain"
    55855505    if [ -f "$_real_fullchain" ] && [ ! "$_ACME_IS_RENEW" ]; then
    55865506      cp "$_real_fullchain" "$_backup_path/fullchain.bak"
     
    57505670  cr="$($_CRONTAB -l | grep "$PROJECT_ENTRY --cron")"
    57515671  if [ "$cr" ]; then
    5752     if _exists uname && uname -a | grep SunOS >/dev/null; then
     5672    if _exists uname && uname -a | grep solaris >/dev/null; then
    57535673      $_CRONTAB -l | sed "/$PROJECT_ENTRY --cron/d" | $_CRONTAB --
    57545674    else
     
    57905710  fi
    57915711
    5792   . "$DOMAIN_CONF"
    5793   _debug Le_API "$Le_API"
    5794 
    5795   if [ "$Le_API" ]; then
    5796     if [ "$Le_API" != "$ACME_DIRECTORY" ]; then
    5797       _clearAPI
    5798     fi
    5799     export ACME_DIRECTORY="$Le_API"
    5800     #reload ca configs
    5801     ACCOUNT_KEY_PATH=""
    5802     ACCOUNT_JSON_PATH=""
    5803     CA_CONF=""
    5804     _debug3 "initpath again."
    5805     _initpath "$Le_Domain" "$_isEcc"
    5806     _initAPI
    5807   fi
    5808 
    58095712  cert="$(_getfile "${CERT_PATH}" "${BEGIN_CERT}" "${END_CERT}" | tr -d "\r\n" | _url_replace)"
    58105713
     
    58165719  _initAPI
    58175720
    5818   data="{\"certificate\": \"$cert\",\"reason\":$_reason}"
    5819 
     5721  if [ "$ACME_VERSION" = "2" ]; then
     5722    data="{\"certificate\": \"$cert\",\"reason\":$_reason}"
     5723  else
     5724    data="{\"resource\": \"revoke-cert\", \"certificate\": \"$cert\"}"
     5725  fi
    58205726  uri="${ACME_REVOKE_CERT}"
    58215727
     
    58865792  _d_domain="$1"
    58875793  _d_type="$2"
    5888   _initpath "$_d_domain" "$_d_type"
    5889 
    5890   . "$DOMAIN_CONF"
    5891   _debug Le_API "$Le_API"
    5892 
    5893   if [ "$Le_API" ]; then
    5894     if [ "$Le_API" != "$ACME_DIRECTORY" ]; then
    5895       _clearAPI
    5896     fi
    5897     export ACME_DIRECTORY="$Le_API"
    5898     #reload ca configs
    5899     ACCOUNT_KEY_PATH=""
    5900     ACCOUNT_JSON_PATH=""
    5901     CA_CONF=""
    5902     _debug3 "initpath again."
    5903     _initpath "$Le_Domain" "$_d_type"
    5904     _initAPI
    5905   fi
    5906 
    5907   _identifiers="{\"type\":\"dns\",\"value\":\"$_d_domain\"}"
    5908   if ! _send_signed_request "$ACME_NEW_ORDER" "{\"identifiers\": [$_identifiers]}"; then
    5909     _err "Can not get domain new order."
    5910     return 1
    5911   fi
    5912   _authorizations_seg="$(echo "$response" | _egrep_o '"authorizations" *: *\[[^\]*\]' | cut -d '[' -f 2 | tr -d ']' | tr -d '"')"
    5913   _debug2 _authorizations_seg "$_authorizations_seg"
    5914   if [ -z "$_authorizations_seg" ]; then
    5915     _err "_authorizations_seg not found."
    5916     _clearup
    5917     _on_issue_err "$_post_hook"
    5918     return 1
    5919   fi
    5920 
    5921   authzUri="$_authorizations_seg"
    5922   _debug2 "authzUri" "$authzUri"
    5923   if ! _send_signed_request "$authzUri"; then
    5924     _err "get to authz error."
    5925     _err "_authorizations_seg" "$_authorizations_seg"
    5926     _err "authzUri" "$authzUri"
    5927     _clearup
    5928     _on_issue_err "$_post_hook"
    5929     return 1
    5930   fi
    5931 
    5932   response="$(echo "$response" | _normalizeJson)"
    5933   _debug2 response "$response"
    5934   _URL_NAME="url"
    5935 
    5936   entries="$(echo "$response" | tr '][' '==' | _egrep_o "challenges\": *=[^=]*=" | tr '}{' '\n\n' | grep "\"status\": *\"valid\"")"
     5794  _initpath
     5795
     5796  if [ "$ACME_VERSION" = "2" ]; then
     5797    _identifiers="{\"type\":\"dns\",\"value\":\"$_d_domain\"}"
     5798    if ! _send_signed_request "$ACME_NEW_ORDER" "{\"identifiers\": [$_identifiers]}"; then
     5799      _err "Can not get domain new order."
     5800      return 1
     5801    fi
     5802    _authorizations_seg="$(echo "$response" | _egrep_o '"authorizations" *: *\[[^\]*\]' | cut -d '[' -f 2 | tr -d ']' | tr -d '"')"
     5803    _debug2 _authorizations_seg "$_authorizations_seg"
     5804    if [ -z "$_authorizations_seg" ]; then
     5805      _err "_authorizations_seg not found."
     5806      _clearup
     5807      _on_issue_err "$_post_hook"
     5808      return 1
     5809    fi
     5810
     5811    authzUri="$_authorizations_seg"
     5812    _debug2 "authzUri" "$authzUri"
     5813    if ! _send_signed_request "$authzUri"; then
     5814      _err "get to authz error."
     5815      _err "_authorizations_seg" "$_authorizations_seg"
     5816      _err "authzUri" "$authzUri"
     5817      _clearup
     5818      _on_issue_err "$_post_hook"
     5819      return 1
     5820    fi
     5821
     5822    response="$(echo "$response" | _normalizeJson)"
     5823    _debug2 response "$response"
     5824    _URL_NAME="url"
     5825  else
     5826    if ! __get_domain_new_authz "$_d_domain"; then
     5827      _err "Can not get domain new authz token."
     5828      return 1
     5829    fi
     5830
     5831    authzUri="$(echo "$responseHeaders" | grep "^Location:" | _head_n 1 | cut -d ':' -f 2- | tr -d "\r\n")"
     5832    _debug "authzUri" "$authzUri"
     5833    if [ "$code" ] && [ ! "$code" = '201' ]; then
     5834      _err "new-authz error: $response"
     5835      return 1
     5836    fi
     5837    _URL_NAME="uri"
     5838  fi
     5839
     5840  entries="$(echo "$response" | tr '][' '==' | _egrep_o "challenges\": *=[^=]*=" | tr '}{' '\n' | grep "\"status\": *\"valid\"")"
    59375841  if [ -z "$entries" ]; then
    59385842    _info "No valid entries found."
     
    59875891    _info "Deactivate: $_vtype"
    59885892
    5989     _djson="{\"status\":\"deactivated\"}"
     5893    if [ "$ACME_VERSION" = "2" ]; then
     5894      _djson="{\"status\":\"deactivated\"}"
     5895    else
     5896      _djson="{\"resource\": \"authz\", \"status\":\"deactivated\"}"
     5897    fi
    59905898
    59915899    if _send_signed_request "$authzUri" "$_djson" && _contains "$response" '"deactivated"'; then
     
    61946102}
    61956103
    6196 # nocron confighome noprofile accountemail
     6104# nocron confighome noprofile
    61976105install() {
    61986106
     
    62046112  _c_home="$2"
    62056113  _noprofile="$3"
    6206   _accountemail="$4"
    6207 
    62086114  if ! _initpath; then
    62096115    _err "Install failed."
     
    63226228      done
    63236229    fi
    6324   fi
    6325 
    6326   if [ "$_accountemail" ]; then
    6327     _saveaccountconf "ACCOUNT_EMAIL" "$_accountemail"
    63286230  fi
    63296231
     
    65506452  --set-default-ca         Used with '--server', Set the default CA to use.
    65516453                           See: $_SERVER_WIKI
    6552   --set-default-chain      Set the default preferred chain for a CA.
    6553                            See: $_PREFERRED_CHAIN_WIKI
    65546454
    65556455
     
    66086508  --config-home <directory>         Specifies the home dir to save all the configurations.
    66096509  --useragent <string>              Specifies the user agent string. it will be saved for future use too.
    6610   -m, --email <email>               Specifies the account email, only valid for the '--install' and '--update-account' command.
     6510  -m, --accountemail <email>        Specifies the account email, only valid for the '--install' and '--update-account' command.
    66116511  --accountkey <file>               Specifies the account key path, only valid for the '--install' command.
    66126512  --days <ndays>                    Specifies the days to renew the cert when using '--issue' command. The default value is $DEFAULT_RENEW days.
     
    66196519  --ca-bundle <file>                Specifies the path to the CA certificate bundle to verify api server's certificate.
    66206520  --ca-path <directory>             Specifies directory containing CA certificates in PEM format, used by wget or curl.
    6621   --no-cron                         Only valid for '--install' command, which means: do not install the default cron job.
     6521  --nocron                          Only valid for '--install' command, which means: do not install the default cron job.
    66226522                                    In this case, the certs will not be renewed automatically.
    6623   --no-profile                      Only valid for '--install' command, which means: do not install aliases to user profile.
     6523  --noprofile                       Only valid for '--install' command, which means: do not install aliases to user profile.
    66246524  --no-color                        Do not output color text.
    66256525  --force-color                     Force output of color text. Useful for non-interactive use with the aha tool for HTML E-Mails.
     
    66596559}
    66606560
    6661 installOnline() {
     6561# nocron noprofile
     6562_installOnline() {
    66626563  _info "Installing from online archive."
    6663 
    6664   _branch="$BRANCH"
    6665   if [ -z "$_branch" ]; then
    6666     _branch="master"
    6667   fi
    6668 
    6669   target="$PROJECT/archive/$_branch.tar.gz"
     6564  _nocron="$1"
     6565  _noprofile="$2"
     6566  if [ ! "$BRANCH" ]; then
     6567    BRANCH="master"
     6568  fi
     6569
     6570  target="$PROJECT/archive/$BRANCH.tar.gz"
    66706571  _info "Downloading $target"
    6671   localname="$_branch.tar.gz"
     6572  localname="$BRANCH.tar.gz"
    66726573  if ! _get "$target" >$localname; then
    66736574    _err "Download error."
     
    66816582    fi
    66826583
    6683     cd "$PROJECT_NAME-$_branch"
     6584    cd "$PROJECT_NAME-$BRANCH"
    66846585    chmod +x $PROJECT_ENTRY
    6685     if ./$PROJECT_ENTRY --install "$@"; then
     6586    if ./$PROJECT_ENTRY install "$_nocron" "" "$_noprofile"; then
    66866587      _info "Install success!"
    66876588      _initpath
     
    66916592    cd ..
    66926593
    6693     rm -rf "$PROJECT_NAME-$_branch"
     6594    rm -rf "$PROJECT_NAME-$BRANCH"
    66946595    rm -f "$localname"
    66956596  )
     
    67006601  shift
    67016602  _hash_url="https://api.github.com/repos/acmesh-official/$PROJECT_NAME/git/refs/$_hash_path"
    6702   _get $_hash_url | tr -d "\r\n" | tr '{},' '\n\n\n' | grep '"sha":' | cut -d '"' -f 4
     6603  _get $_hash_url | tr -d "\r\n" | tr '{},' '\n' | grep '"sha":' | cut -d '"' -f 4
    67036604}
    67046605
     
    67196620    export LE_WORKING_DIR
    67206621    cd "$LE_WORKING_DIR"
    6721     installOnline "--nocron" "--noprofile"
     6622    _installOnline "nocron" "noprofile"
    67226623  ); then
    67236624    _info "Upgrade success!"
     
    67736674}
    67746675
    6775 #server  #keylength
     6676#server
    67766677_selectServer() {
    67776678  _server="$1"
    6778   _skeylength="$2"
    67796679  _server_lower="$(echo "$_server" | _lower_case)"
    67806680  _sindex=0
     
    67876687        _debug2 "_selectServer match $sname"
    67886688        _serverdir="$(_getfield "$CA_SERVERS" $_sindex)"
    6789         if [ "$_serverdir" = "$CA_SSLCOM_RSA" ] && _isEccKey "$_skeylength"; then
    6790           _serverdir="$CA_SSLCOM_ECC"
    6791         fi
    67926689        _debug "Selected server: $_serverdir"
    67936690        ACME_DIRECTORY="$_serverdir"
     
    68066703  if [ -z "$caurl" ]; then
    68076704    caurl="$DEFAULT_CA"
    6808   fi
    6809   if [ "$CA_SSLCOM_ECC" = "$caurl" ]; then
    6810     caurl="$CA_SSLCOM_RSA" #just hack to get the short name
    68116705  fi
    68126706  caurl_lower="$(echo $caurl | _lower_case)"
     
    68366730  _saveaccountconf "DEFAULT_ACME_SERVER" "$ACME_DIRECTORY"
    68376731  _info "Changed default CA to: $(__green "$ACME_DIRECTORY")"
    6838 }
    6839 
    6840 #preferred-chain
    6841 setdefaultchain() {
    6842   _initpath
    6843   _preferred_chain="$1"
    6844   if [ -z "$_preferred_chain" ]; then
    6845     _err "Please give a '--preferred-chain value' value."
    6846     return 1
    6847   fi
    6848   mkdir -p "$CA_DIR"
    6849   _savecaconf "DEFAULT_PREFERRED_CHAIN" "$_preferred_chain"
    68506732}
    68516733
     
    69186800      _CMD="install"
    69196801      ;;
    6920     --install-online)
    6921       shift
    6922       installOnline "$@"
    6923       return
    6924       ;;
    69256802    --uninstall)
    69266803      _CMD="uninstall"
     
    70006877    --set-default-ca)
    70016878      _CMD="setdefaultca"
    7002       ;;
    7003     --set-default-chain)
    7004       _CMD="setdefaultchain"
    70056879      ;;
    70066880    -d | --domain)
     
    70176891        fi
    70186892
     6893        if _startswith "$_dvalue" "*."; then
     6894          _debug "Wildcard domain"
     6895          export ACME_VERSION=2
     6896        fi
    70196897        if [ -z "$_domain" ]; then
    70206898          _domain="$_dvalue"
     
    70396917    --server)
    70406918      _server="$2"
     6919      _selectServer "$_server"
    70416920      shift
    70426921      ;;
     
    71377016      shift
    71387017      ;;
     7018
    71397019    --keylength | -k)
    71407020      _keylength="$2"
     
    71457025      shift
    71467026      ;;
     7027
    71477028    --cert-file | --certpath)
    71487029      _cert_file="$2"
     
    71937074      shift
    71947075      ;;
    7195     -m | --email | --accountemail)
     7076    -m | --accountemail)
    71967077      _accountemail="$2"
    7197       export ACCOUNT_EMAIL="$_accountemail"
     7078      ACCOUNT_EMAIL="$_accountemail"
    71987079      shift
    71997080      ;;
     
    72387119      shift
    72397120      ;;
    7240     --no-cron | --nocron)
     7121    --nocron)
    72417122      _nocron="1"
    72427123      ;;
    7243     --no-profile | --noprofile)
     7124    --noprofile)
    72447125      _noprofile="1"
    72457126      ;;
     
    74077288    shift 1
    74087289  done
    7409 
    7410   if [ "$_server" ]; then
    7411     _selectServer "$_server" "${_ecc:-$_keylength}"
    7412   fi
    74137290
    74147291  if [ "${_CMD}" != "install" ]; then
     
    74657342  _debug "Running cmd: ${_CMD}"
    74667343  case "${_CMD}" in
    7467   install) install "$_nocron" "$_confighome" "$_noprofile" "$_accountemail" ;;
     7344  install) install "$_nocron" "$_confighome" "$_noprofile" ;;
    74687345  uninstall) uninstall "$_nocron" ;;
    74697346  upgrade) upgrade ;;
     
    74757352    ;;
    74767353  signcsr)
    7477     signcsr "$_csr" "$_webroot" "$_cert_file" "$_key_file" "$_ca_file" "$_reloadcmd" "$_fullchain_file" "$_pre_hook" "$_post_hook" "$_renew_hook" "$_local_address" "$_challenge_alias" "$_preferred_chain"
     7354    signcsr "$_csr" "$_webroot" "$_cert_file" "$_key_file" "$_ca_file" "$_reloadcmd" "$_fullchain_file" "$_pre_hook" "$_post_hook" "$_renew_hook" "$_local_address" "$_challenge_alias"
    74787355    ;;
    74797356  showcsr)
     
    75347411    setdefaultca
    75357412    ;;
    7536   setdefaultchain)
    7537     setdefaultchain "$_preferred_chain"
    7538     ;;
    75397413  *)
    75407414    if [ "$_CMD" ]; then
     
    75817455}
    75827456
     7457if [ "$INSTALLONLINE" ]; then
     7458  INSTALLONLINE=""
     7459  _installOnline
     7460  exit
     7461fi
     7462
    75837463main() {
    75847464  [ -z "$1" ] && showhelp && return
  • npl/syn3/acme/root/usr/bin/syn3-acme-issue

    r3daa803 r79f7e49  
    1515
    1616if [ "$EXIT" == "0" ]; then
    17         cat /usr/webint/ssl/server.crt /usr/webint/ssl/server.pem  > /usr/webint/ssl/certandkey.pem
     17        cat /usr/webint/ssl/server.crt /usr/webint/ssl/server.key  > /usr/webint/ssl/certandkey.pem
    1818        syn3-state certbot OK "SSL certificate valid."
    1919fi
  • npl/syn3/acme/root/usr/bin/syn3-acme-renew

    r3daa803 r79f7e49  
    1515
    1616if [ "$EXIT" == "0" ]; then
    17         cat /usr/webint/ssl/server.crt /usr/webint/ssl/server.pem  > /usr/webint/ssl/certandkey.pem
     17        cat /usr/webint/ssl/server.crt /usr/webint/ssl/server.key  > /usr/webint/ssl/certandkey.pem
    1818        syn3-state certbot OK "SSL certificate valid. `cat $STATUS`"
    1919else
  • npl/syn3/acme/syn3_acme.build

    r3daa803 r79f7e49  
    1 12
     110
  • npl/syn3/acme/syn3_acme.md5

    r3daa803 r79f7e49  
    11d41d8cd98f00b204e9800998ecf8427e  ./root/etc/webint/SSL_DOMAINS.new
    2 41f48d3c2742cbbdf0fe9b7bf77740c0  ./root/usr/bin/acme.sh
     20418c2dac1c09a1e0a5a923de7155251  ./root/usr/bin/acme.sh
    33a0e5403f61c08e4eda04cd2e61d7938a  ./root/usr/bin/syn3-acme
    4 a6acd24402cd102ba0fa6698140dc0b2  ./root/usr/bin/syn3-acme-issue
    5 4a90cca626fec2de3d266c94c0e7d321  ./root/usr/bin/syn3-acme-renew
    6 8bf81f0d178c08b77421b11d71fcf347  ./syn3_acme.pkg
     459aa594e0d86791b3aa9b7b1a3e88e42  ./root/usr/bin/syn3-acme-issue
     5917bbc278f45bd8ab36a946d4898dd0f  ./root/usr/bin/syn3-acme-renew
     60301b5ee1cb78f1410fe47edbf32e780  ./syn3_acme.pkg
    771a66f2a0cb707f264b0268ee3d4956d3  ./syn3_acme.SlackBuild
    8 33724e469f08288ccd67b04f39cae180  ./syn3_acme.SlackBuild.log.gz
     86c17d788610977961a07f821dad6ccc3  ./syn3_acme.SlackBuild.log.gz
Note: See TracChangeset for help on using the changeset viewer.