Changeset 6e9c61f


Ignore:
Timestamp:
12/14/20 16:40:34 (4 years ago)
Author:
Edwin Eefting <edwin@datux.nl>
Branches:
master
Children:
a051af0
Parents:
30f002a
Message:

acme.sh update. also generate cert+privkey for qmail

Location:
npl/syn3/acme
Files:
7 edited

Legend:

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

    r30f002a r6e9c61f  
    11#!/usr/bin/env sh
    22
    3 VER=2.8.6
     3VER=2.8.8
    44
    55PROJECT_NAME="acme.sh"
     
    2424LETSENCRYPT_STAGING_CA_V1="https://acme-staging.api.letsencrypt.org/directory"
    2525
    26 LETSENCRYPT_CA_V2="https://acme-v02.api.letsencrypt.org/directory"
    27 LETSENCRYPT_STAGING_CA_V2="https://acme-staging-v02.api.letsencrypt.org/directory"
    28 
    29 DEFAULT_CA=$LETSENCRYPT_CA_V2
    30 DEFAULT_STAGING_CA=$LETSENCRYPT_STAGING_CA_V2
     26CA_LETSENCRYPT_V2="https://acme-v02.api.letsencrypt.org/directory"
     27CA_LETSENCRYPT_V2_TEST="https://acme-staging-v02.api.letsencrypt.org/directory"
     28
     29CA_BUYPASS="https://api.buypass.com/acme/directory"
     30CA_BUYPASS_TEST="https://api.test4.buypass.no/acme/directory"
     31
     32CA_ZEROSSL="https://acme.zerossl.com/v2/DV90"
     33_ZERO_EAB_ENDPOINT="http://api.zerossl.com/acme/eab-credentials-email"
     34
     35DEFAULT_CA=$CA_LETSENCRYPT_V2
     36DEFAULT_STAGING_CA=$CA_LETSENCRYPT_V2_TEST
     37
     38CA_NAMES="
     39LetsEncrypt.org,letsencrypt
     40LetsEncrypt.org_test,letsencrypt_test,letsencrypttest
     41BuyPass.com,buypass
     42BuyPass.com_test,buypass_test,buypasstest
     43ZeroSSL.com,zerossl
     44"
     45
     46CA_SERVERS="$CA_LETSENCRYPT_V2,$CA_LETSENCRYPT_V2_TEST,$CA_BUYPASS,$CA_BUYPASS_TEST,$CA_ZEROSSL"
    3147
    3248DEFAULT_USER_AGENT="$PROJECT_NAME/$VER ($PROJECT)"
    33 DEFAULT_ACCOUNT_EMAIL=""
    3449
    3550DEFAULT_ACCOUNT_KEY_LENGTH=2048
     
    3752
    3853DEFAULT_OPENSSL_BIN="openssl"
    39 
    40 _OLD_CA_HOST="https://acme-v01.api.letsencrypt.org"
    41 _OLD_STAGE_CA_HOST="https://acme-staging.api.letsencrypt.org"
    4254
    4355VTYPE_HTTP="http-01"
     
    4860
    4961DEFAULT_RENEW=60
    50 
    51 DEFAULT_DNS_SLEEP=120
    5262
    5363NO_VALUE="no"
     
    137147_DNS_MANUAL_WIKI="https://github.com/acmesh-official/acme.sh/wiki/dns-manual-mode"
    138148
     149_DNS_API_WIKI="https://github.com/acmesh-official/acme.sh/wiki/dnsapi"
     150
    139151_NOTIFY_WIKI="https://github.com/acmesh-official/acme.sh/wiki/notify"
    140152
    141153_SUDO_WIKI="https://github.com/acmesh-official/acme.sh/wiki/sudo"
     154
     155_REVOKE_WIKI="https://github.com/acmesh-official/acme.sh/wiki/revokecert"
     156
     157_ZEROSSL_WIKI="https://github.com/acmesh-official/acme.sh/wiki/ZeroSSL.com-CA"
     158
     159_SERVER_WIKI="https://github.com/acmesh-official/acme.sh/wiki/Server"
     160
     161_PREFERRED_CHAIN_WIKI="https://github.com/acmesh-official/acme.sh/wiki/Preferred-Chain"
    142162
    143163_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."
     
    189209    ${ACME_OPENSSL_BIN:-openssl} version 2>&1
    190210  else
    191     echo "$ACME_OPENSSL_BIN doesn't exists."
     211    echo "$ACME_OPENSSL_BIN doesn't exist."
    192212  fi
    193213
     
    196216    $_APACHECTL -V 2>&1
    197217  else
    198     echo "apache doesn't exists."
     218    echo "apache doesn't exist."
    199219  fi
    200220
     
    203223    nginx -V 2>&1
    204224  else
    205     echo "nginx doesn't exists."
     225    echo "nginx doesn't exist."
    206226  fi
    207227
     
    210230    socat -V 2>&1
    211231  else
    212     _debug "socat doesn't exists."
     232    _debug "socat doesn't exist."
    213233  fi
    214234}
     
    505525  _ch=$1
    506526  case "${_ch}" in
    507     a | A)
    508       printf "10"
    509       ;;
    510     b | B)
    511       printf "11"
    512       ;;
    513     c | C)
    514       printf "12"
    515       ;;
    516     d | D)
    517       printf "13"
    518       ;;
    519     e | E)
    520       printf "14"
    521       ;;
    522     f | F)
    523       printf "15"
    524       ;;
    525     *)
    526       printf "%s" "$_ch"
    527       ;;
     527  a | A)
     528    printf "10"
     529    ;;
     530  b | B)
     531    printf "11"
     532    ;;
     533  c | C)
     534    printf "12"
     535    ;;
     536  d | D)
     537    printf "13"
     538    ;;
     539  e | E)
     540    printf "14"
     541    ;;
     542  f | F)
     543    printf "15"
     544    ;;
     545  *)
     546    printf "%s" "$_ch"
     547    ;;
    528548  esac
    529549
     
    633653    #upper case
    634654    case "${_hex_code}" in
    635       "41")
    636         printf "%s" "A"
    637         ;;
    638       "42")
    639         printf "%s" "B"
    640         ;;
    641       "43")
    642         printf "%s" "C"
    643         ;;
    644       "44")
    645         printf "%s" "D"
    646         ;;
    647       "45")
    648         printf "%s" "E"
    649         ;;
    650       "46")
    651         printf "%s" "F"
    652         ;;
    653       "47")
    654         printf "%s" "G"
    655         ;;
    656       "48")
    657         printf "%s" "H"
    658         ;;
    659       "49")
    660         printf "%s" "I"
    661         ;;
    662       "4a")
    663         printf "%s" "J"
    664         ;;
    665       "4b")
    666         printf "%s" "K"
    667         ;;
    668       "4c")
    669         printf "%s" "L"
    670         ;;
    671       "4d")
    672         printf "%s" "M"
    673         ;;
    674       "4e")
    675         printf "%s" "N"
    676         ;;
    677       "4f")
    678         printf "%s" "O"
    679         ;;
    680       "50")
    681         printf "%s" "P"
    682         ;;
    683       "51")
    684         printf "%s" "Q"
    685         ;;
    686       "52")
    687         printf "%s" "R"
    688         ;;
    689       "53")
    690         printf "%s" "S"
    691         ;;
    692       "54")
    693         printf "%s" "T"
    694         ;;
    695       "55")
    696         printf "%s" "U"
    697         ;;
    698       "56")
    699         printf "%s" "V"
    700         ;;
    701       "57")
    702         printf "%s" "W"
    703         ;;
    704       "58")
    705         printf "%s" "X"
    706         ;;
    707       "59")
    708         printf "%s" "Y"
    709         ;;
    710       "5a")
    711         printf "%s" "Z"
    712         ;;
     655    "41")
     656      printf "%s" "A"
     657      ;;
     658    "42")
     659      printf "%s" "B"
     660      ;;
     661    "43")
     662      printf "%s" "C"
     663      ;;
     664    "44")
     665      printf "%s" "D"
     666      ;;
     667    "45")
     668      printf "%s" "E"
     669      ;;
     670    "46")
     671      printf "%s" "F"
     672      ;;
     673    "47")
     674      printf "%s" "G"
     675      ;;
     676    "48")
     677      printf "%s" "H"
     678      ;;
     679    "49")
     680      printf "%s" "I"
     681      ;;
     682    "4a")
     683      printf "%s" "J"
     684      ;;
     685    "4b")
     686      printf "%s" "K"
     687      ;;
     688    "4c")
     689      printf "%s" "L"
     690      ;;
     691    "4d")
     692      printf "%s" "M"
     693      ;;
     694    "4e")
     695      printf "%s" "N"
     696      ;;
     697    "4f")
     698      printf "%s" "O"
     699      ;;
     700    "50")
     701      printf "%s" "P"
     702      ;;
     703    "51")
     704      printf "%s" "Q"
     705      ;;
     706    "52")
     707      printf "%s" "R"
     708      ;;
     709    "53")
     710      printf "%s" "S"
     711      ;;
     712    "54")
     713      printf "%s" "T"
     714      ;;
     715    "55")
     716      printf "%s" "U"
     717      ;;
     718    "56")
     719      printf "%s" "V"
     720      ;;
     721    "57")
     722      printf "%s" "W"
     723      ;;
     724    "58")
     725      printf "%s" "X"
     726      ;;
     727    "59")
     728      printf "%s" "Y"
     729      ;;
     730    "5a")
     731      printf "%s" "Z"
     732      ;;
    713733
    714734      #lower case
    715       "61")
    716         printf "%s" "a"
    717         ;;
    718       "62")
    719         printf "%s" "b"
    720         ;;
    721       "63")
    722         printf "%s" "c"
    723         ;;
    724       "64")
    725         printf "%s" "d"
    726         ;;
    727       "65")
    728         printf "%s" "e"
    729         ;;
    730       "66")
    731         printf "%s" "f"
    732         ;;
    733       "67")
    734         printf "%s" "g"
    735         ;;
    736       "68")
    737         printf "%s" "h"
    738         ;;
    739       "69")
    740         printf "%s" "i"
    741         ;;
    742       "6a")
    743         printf "%s" "j"
    744         ;;
    745       "6b")
    746         printf "%s" "k"
    747         ;;
    748       "6c")
    749         printf "%s" "l"
    750         ;;
    751       "6d")
    752         printf "%s" "m"
    753         ;;
    754       "6e")
    755         printf "%s" "n"
    756         ;;
    757       "6f")
    758         printf "%s" "o"
    759         ;;
    760       "70")
    761         printf "%s" "p"
    762         ;;
    763       "71")
    764         printf "%s" "q"
    765         ;;
    766       "72")
    767         printf "%s" "r"
    768         ;;
    769       "73")
    770         printf "%s" "s"
    771         ;;
    772       "74")
    773         printf "%s" "t"
    774         ;;
    775       "75")
    776         printf "%s" "u"
    777         ;;
    778       "76")
    779         printf "%s" "v"
    780         ;;
    781       "77")
    782         printf "%s" "w"
    783         ;;
    784       "78")
    785         printf "%s" "x"
    786         ;;
    787       "79")
    788         printf "%s" "y"
    789         ;;
    790       "7a")
    791         printf "%s" "z"
    792         ;;
     735    "61")
     736      printf "%s" "a"
     737      ;;
     738    "62")
     739      printf "%s" "b"
     740      ;;
     741    "63")
     742      printf "%s" "c"
     743      ;;
     744    "64")
     745      printf "%s" "d"
     746      ;;
     747    "65")
     748      printf "%s" "e"
     749      ;;
     750    "66")
     751      printf "%s" "f"
     752      ;;
     753    "67")
     754      printf "%s" "g"
     755      ;;
     756    "68")
     757      printf "%s" "h"
     758      ;;
     759    "69")
     760      printf "%s" "i"
     761      ;;
     762    "6a")
     763      printf "%s" "j"
     764      ;;
     765    "6b")
     766      printf "%s" "k"
     767      ;;
     768    "6c")
     769      printf "%s" "l"
     770      ;;
     771    "6d")
     772      printf "%s" "m"
     773      ;;
     774    "6e")
     775      printf "%s" "n"
     776      ;;
     777    "6f")
     778      printf "%s" "o"
     779      ;;
     780    "70")
     781      printf "%s" "p"
     782      ;;
     783    "71")
     784      printf "%s" "q"
     785      ;;
     786    "72")
     787      printf "%s" "r"
     788      ;;
     789    "73")
     790      printf "%s" "s"
     791      ;;
     792    "74")
     793      printf "%s" "t"
     794      ;;
     795    "75")
     796      printf "%s" "u"
     797      ;;
     798    "76")
     799      printf "%s" "v"
     800      ;;
     801    "77")
     802      printf "%s" "w"
     803      ;;
     804    "78")
     805      printf "%s" "x"
     806      ;;
     807    "79")
     808      printf "%s" "y"
     809      ;;
     810    "7a")
     811      printf "%s" "z"
     812      ;;
    793813      #numbers
    794       "30")
    795         printf "%s" "0"
    796         ;;
    797       "31")
    798         printf "%s" "1"
    799         ;;
    800       "32")
    801         printf "%s" "2"
    802         ;;
    803       "33")
    804         printf "%s" "3"
    805         ;;
    806       "34")
    807         printf "%s" "4"
    808         ;;
    809       "35")
    810         printf "%s" "5"
    811         ;;
    812       "36")
    813         printf "%s" "6"
    814         ;;
    815       "37")
    816         printf "%s" "7"
    817         ;;
    818       "38")
    819         printf "%s" "8"
    820         ;;
    821       "39")
    822         printf "%s" "9"
    823         ;;
    824       "2d")
    825         printf "%s" "-"
    826         ;;
    827       "5f")
    828         printf "%s" "_"
    829         ;;
    830       "2e")
    831         printf "%s" "."
    832         ;;
    833       "7e")
    834         printf "%s" "~"
    835         ;;
    836       #other hex
    837       *)
    838         printf '%%%s' "$_hex_code"
    839         ;;
     814    "30")
     815      printf "%s" "0"
     816      ;;
     817    "31")
     818      printf "%s" "1"
     819      ;;
     820    "32")
     821      printf "%s" "2"
     822      ;;
     823    "33")
     824      printf "%s" "3"
     825      ;;
     826    "34")
     827      printf "%s" "4"
     828      ;;
     829    "35")
     830      printf "%s" "5"
     831      ;;
     832    "36")
     833      printf "%s" "6"
     834      ;;
     835    "37")
     836      printf "%s" "7"
     837      ;;
     838    "38")
     839      printf "%s" "8"
     840      ;;
     841    "39")
     842      printf "%s" "9"
     843      ;;
     844    "2d")
     845      printf "%s" "-"
     846      ;;
     847    "5f")
     848      printf "%s" "_"
     849      ;;
     850    "2e")
     851      printf "%s" "."
     852      ;;
     853    "7e")
     854      printf "%s" "~"
     855      ;;
     856    #other hex
     857    *)
     858      printf '%%%s' "$_hex_code"
     859      ;;
    840860    esac
    841861  done
     
    847867  _debug3 "_j_str" "$_j_str"
    848868  echo "$_j_str" | _hex_dump | _lower_case | sed 's/0a/5c 6e/g' | tr -d ' ' | _h2b | tr -d "\r\n"
     869}
     870
     871#from: http:\/\/  to http://
     872_json_decode() {
     873  _j_str="$(sed 's#\\/#/#g')"
     874  _debug3 "_json_decode"
     875  _debug3 "_j_str" "$_j_str"
     876  echo "$_j_str"
    849877}
    850878
     
    929957  _cf="$1"
    930958  if [ "$DEBUG" ]; then
    931     openssl x509 -noout -text -in "$_cf"
    932   else
    933     openssl x509 -noout -text -in "$_cf" >/dev/null 2>&1
     959    ${ACME_OPENSSL_BIN:-openssl} x509 -noout -text -in "$_cf"
     960  else
     961    ${ACME_OPENSSL_BIN:-openssl} x509 -noout -text -in "$_cf" >/dev/null 2>&1
    934962  fi
    935963}
     
    9961024  _sign_openssl="${ACME_OPENSSL_BIN:-openssl} dgst -sign $keyfile "
    9971025
    998   if grep "BEGIN RSA PRIVATE KEY" "$keyfile" >/dev/null 2>&1; then
     1026  if grep "BEGIN RSA PRIVATE KEY" "$keyfile" >/dev/null 2>&1 || grep "BEGIN PRIVATE KEY" "$keyfile" >/dev/null 2>&1; then
    9991027    $_sign_openssl -$alg | _base64
    10001028  elif grep "BEGIN EC PRIVATE KEY" "$keyfile" >/dev/null 2>&1; then
     
    10071035    _debug3 "_signedECText" "$_signedECText"
    10081036    _ec_r="$(echo "$_signedECText" | _head_n 2 | _tail_n 1 | cut -d : -f 4 | tr -d "\r\n")"
     1037    _ec_s="$(echo "$_signedECText" | _head_n 3 | _tail_n 1 | cut -d : -f 4 | tr -d "\r\n")"
     1038    if [ "$__ECC_KEY_LEN" -eq "256" ]; then
     1039      while [ "${#_ec_r}" -lt "64" ]; do
     1040        _ec_r="0${_ec_r}"
     1041      done
     1042      while [ "${#_ec_s}" -lt "64" ]; do
     1043        _ec_s="0${_ec_s}"
     1044      done
     1045    fi
     1046    if [ "$__ECC_KEY_LEN" -eq "384" ]; then
     1047      while [ "${#_ec_r}" -lt "96" ]; do
     1048        _ec_r="0${_ec_r}"
     1049      done
     1050      while [ "${#_ec_s}" -lt "96" ]; do
     1051        _ec_s="0${_ec_s}"
     1052      done
     1053    fi
     1054    if [ "$__ECC_KEY_LEN" -eq "512" ]; then
     1055      while [ "${#_ec_r}" -lt "132" ]; do
     1056        _ec_r="0${_ec_r}"
     1057      done
     1058      while [ "${#_ec_s}" -lt "132" ]; do
     1059        _ec_s="0${_ec_s}"
     1060      done
     1061    fi
    10091062    _debug3 "_ec_r" "$_ec_r"
    1010     _ec_s="$(echo "$_signedECText" | _head_n 3 | _tail_n 1 | cut -d : -f 4 | tr -d "\r\n")"
    10111063    _debug3 "_ec_s" "$_ec_s"
    10121064    printf "%s" "$_ec_r$_ec_s" | _h2b | _base64
     
    10261078  fi
    10271079
    1028   [ "$_length" != "1024" ] \
    1029     && [ "$_length" != "2048" ] \
    1030     && [ "$_length" != "3072" ] \
    1031     && [ "$_length" != "4096" ] \
    1032     && [ "$_length" != "8192" ]
     1080  [ "$_length" != "1024" ] &&
     1081    [ "$_length" != "2048" ] &&
     1082    [ "$_length" != "3072" ] &&
     1083    [ "$_length" != "4096" ] &&
     1084    [ "$_length" != "8192" ]
    10331085}
    10341086
     
    11671219    printf -- "\nsubjectAltName=$alt" >>"$csrconf"
    11681220  fi
    1169   if [ "$Le_OCSP_Staple" ] || [ "$Le_OCSP_Stable" ]; then
     1221  if [ "$Le_OCSP_Staple" = "1" ]; then
    11701222    _savedomainconf Le_OCSP_Staple "$Le_OCSP_Staple"
    1171     _cleardomainconf Le_OCSP_Stable
    11721223    printf -- "\nbasicConstraints = CA:FALSE\n1.3.6.1.5.5.7.1.24=DER:30:03:02:01:05" >>"$csrconf"
    11731224  fi
     
    13251376  pfxPassword="$2"
    13261377  if [ -z "$domain" ]; then
    1327     _usage "Usage: $PROJECT_ENTRY --toPkcs -d domain [--password pfx-password]"
     1378    _usage "Usage: $PROJECT_ENTRY --to-pkcs12 --domain <domain.tld> [--password <password>] [--ecc]"
    13281379    return 1
    13291380  fi
     
    13461397
    13471398  if [ -z "$domain" ]; then
    1348     _usage "Usage: $PROJECT_ENTRY --toPkcs8 -d domain [--ecc]"
     1399    _usage "Usage: $PROJECT_ENTRY --to-pkcs8 --domain <domain.tld> [--ecc]"
    13491400    return 1
    13501401  fi
     
    13661417  _info "Creating account key"
    13671418  if [ -z "$1" ]; then
    1368     _usage "Usage: $PROJECT_ENTRY --createAccountKey --accountkeylength 2048"
     1419    _usage "Usage: $PROJECT_ENTRY --create-account-key [--accountkeylength <bits>]"
    13691420    return
    13701421  fi
     
    14091460  _info "Creating domain key"
    14101461  if [ -z "$1" ]; then
    1411     _usage "Usage: $PROJECT_ENTRY --createDomainKey -d domain.com  [ --keylength 2048 ]"
     1462    _usage "Usage: $PROJECT_ENTRY --create-domain-key --domain <domain.tld> [--keylength <bits>]"
    14121463    return
    14131464  fi
     
    14231474  _initpath "$domain" "$_cdl"
    14241475
    1425   if [ ! -f "$CERT_KEY_PATH" ] || [ ! -s "$CERT_KEY_PATH" ] || ([ "$FORCE" ] && ! [ "$IS_RENEW" ]) || [ "$Le_ForceNewDomainKey" = "1" ]; then
     1476  if [ ! -f "$CERT_KEY_PATH" ] || [ ! -s "$CERT_KEY_PATH" ] || ([ "$FORCE" ] && ! [ "$_ACME_IS_RENEW" ]) || [ "$Le_ForceNewDomainKey" = "1" ]; then
    14261477    if _createkey "$_cdl" "$CERT_KEY_PATH"; then
    14271478      _savedomainconf Le_Keylength "$_cdl"
     
    14331484    fi
    14341485  else
    1435     if [ "$IS_RENEW" ]; then
     1486    if [ "$_ACME_IS_RENEW" ]; then
    14361487      _info "Domain key exists, skip"
    14371488      return 0
     
    14491500  _info "Creating csr"
    14501501  if [ -z "$1" ]; then
    1451     _usage "Usage: $PROJECT_ENTRY --createCSR -d domain1.com [-d domain2.com  -d domain3.com ... ]"
     1502    _usage "Usage: $PROJECT_ENTRY --create-csr --domain <domain.tld> [--domain <domain2.tld> ...]"
    14521503    return
    14531504  fi
     
    14591510  _initpath "$domain" "$_isEcc"
    14601511
    1461   if [ -f "$CSR_PATH" ] && [ "$IS_RENEW" ] && [ -z "$FORCE" ]; then
     1512  if [ -f "$CSR_PATH" ] && [ "$_ACME_IS_RENEW" ] && [ -z "$FORCE" ]; then
    14621513    _info "CSR exists, skip"
    14631514    return
     
    14751526_url_replace() {
    14761527  tr '/+' '_-' | tr -d '= '
     1528}
     1529
     1530#base64 string
     1531_durl_replace_base64() {
     1532  _l=$((${#1} % 4))
     1533  if [ $_l -eq 2 ]; then
     1534    _s="$1"'=='
     1535  elif [ $_l -eq 3 ]; then
     1536    _s="$1"'='
     1537  else
     1538    _s="$1"
     1539  fi
     1540  echo "$_s" | tr '_-' '/+'
    14771541}
    14781542
     
    15671631      _debug3 crv_oid "$crv_oid"
    15681632      case "${crv_oid}" in
    1569         "prime256v1")
    1570           crv="P-256"
    1571           __ECC_KEY_LEN=256
    1572           ;;
    1573         "secp384r1")
    1574           crv="P-384"
    1575           __ECC_KEY_LEN=384
    1576           ;;
    1577         "secp521r1")
    1578           crv="P-521"
    1579           __ECC_KEY_LEN=512
    1580           ;;
    1581         *)
    1582           _err "ECC oid : $crv_oid"
    1583           return 1
    1584           ;;
     1633      "prime256v1")
     1634        crv="P-256"
     1635        __ECC_KEY_LEN=256
     1636        ;;
     1637      "secp384r1")
     1638        crv="P-384"
     1639        __ECC_KEY_LEN=384
     1640        ;;
     1641      "secp521r1")
     1642        crv="P-521"
     1643        __ECC_KEY_LEN=512
     1644        ;;
     1645      *)
     1646        _err "ECC oid : $crv_oid"
     1647        return 1
     1648        ;;
    15851649      esac
    15861650      _debug3 crv "$crv"
     
    16591723}
    16601724
     1725#clear all the https envs to cause _inithttp() to run next time.
     1726_resethttp() {
     1727  __HTTP_INITIALIZED=""
     1728  _ACME_CURL=""
     1729  _ACME_WGET=""
     1730  ACME_HTTP_NO_REDIRECTS=""
     1731}
     1732
    16611733_inithttp() {
    16621734
     
    16741746
    16751747  if [ -z "$_ACME_CURL" ] && _exists "curl"; then
    1676     _ACME_CURL="curl -L --silent --dump-header $HTTP_HEADER "
     1748    _ACME_CURL="curl --silent --dump-header $HTTP_HEADER "
     1749    if [ -z "$ACME_HTTP_NO_REDIRECTS" ]; then
     1750      _ACME_CURL="$_ACME_CURL -L "
     1751    fi
    16771752    if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ]; then
    16781753      _CURL_DUMP="$(_mktemp)"
     
    16931768  if [ -z "$_ACME_WGET" ] && _exists "wget"; then
    16941769    _ACME_WGET="wget -q"
     1770    if [ "$ACME_HTTP_NO_REDIRECTS" ]; then
     1771      _ACME_WGET="$_ACME_WGET --max-redirect 0 "
     1772    fi
    16951773    if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ]; then
    16961774      _ACME_WGET="$_ACME_WGET -d "
     
    19802058    fi
    19812059    if [ "$ACME_VERSION" = "2" ]; then
    1982       if [ "$url" = "$ACME_NEW_ACCOUNT" ] || [ "$url" = "$ACME_REVOKE_CERT" ]; 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
    19832063        protected="$JWK_HEADERPLACE_PART1$nonce\", \"url\": \"${url}$JWK_HEADERPLACE_PART2, \"jwk\": $jwk"'}'
    19842064      else
     
    20212101    _debug2 original "$response"
    20222102    if echo "$responseHeaders" | grep -i "Content-Type: *application/json" >/dev/null 2>&1; then
    2023       response="$(echo "$response" | _normalizeJson)"
     2103      response="$(echo "$response" | _json_decode | _normalizeJson)"
    20242104    fi
    20252105    _debug2 response "$response"
     
    24382518      return 1
    24392519    fi
     2520    response=$(echo "$response" | _json_decode)
    24402521    _debug2 "response" "$response"
    24412522
     
    25202601  fi
    25212602
    2522   if [ "$ACME_IN_CRON" ]; then
     2603  if [ "$_ACME_IN_CRON" ]; then
    25232604    if [ ! "$_USER_PATH_EXPORTED" ]; then
    25242605      _USER_PATH_EXPORTED=1
     
    25312612  fi
    25322613
    2533   if [ "$ACME_VERSION" = "2" ]; then
    2534     DEFAULT_CA="$LETSENCRYPT_CA_V2"
    2535     DEFAULT_STAGING_CA="$LETSENCRYPT_STAGING_CA_V2"
    2536   fi
    2537 
    25382614  if [ -z "$ACME_DIRECTORY" ]; then
    2539     if [ -z "$STAGE" ]; then
    2540       ACME_DIRECTORY="$DEFAULT_CA"
     2615    if [ "$STAGE" ]; then
     2616      ACME_DIRECTORY="$DEFAULT_STAGING_CA"
     2617      _info "Using ACME_DIRECTORY: $ACME_DIRECTORY"
    25412618    else
    2542       ACME_DIRECTORY="$DEFAULT_STAGING_CA"
    2543       _info "Using stage ACME_DIRECTORY: $ACME_DIRECTORY"
     2619      default_acme_server=$(_readaccountconf "DEFAULT_ACME_SERVER")
     2620      _debug default_acme_server "$default_acme_server"
     2621      if [ "$default_acme_server" ]; then
     2622        ACME_DIRECTORY="$default_acme_server"
     2623      else
     2624        ACME_DIRECTORY="$DEFAULT_CA"
     2625      fi
    25442626    fi
    25452627  fi
     
    27932875  apacheVer="$($_APACHECTL -V | grep "Server version:" | cut -d : -f 2 | cut -d " " -f 2 | cut -d '/' -f 2)"
    27942876  _debug "apacheVer" "$apacheVer"
    2795   apacheMajer="$(echo "$apacheVer" | cut -d . -f 1)"
     2877  apacheMajor="$(echo "$apacheVer" | cut -d . -f 1)"
    27962878  apacheMinor="$(echo "$apacheVer" | cut -d . -f 2)"
    27972879
    2798   if [ "$apacheVer" ] && [ "$apacheMajer$apacheMinor" -ge "24" ]; then
     2880  if [ "$apacheVer" ] && [ "$apacheMajor$apacheMinor" -ge "24" ]; then
    27992881    echo "
    28002882Alias /.well-known/acme-challenge  $ACME_DIR
     
    28212903      _err "The apache config file is restored."
    28222904    else
    2823       _err "Sorry, The apache config file can not be restored, please report bug."
     2905      _err "Sorry, the apache config file can not be restored, please report bug."
    28242906    fi
    28252907    return 1
     
    33213403  fi
    33223404
    3323   if [ "$IS_RENEW" = "1" ] && _hasfield "$Le_Webroot" "$W_DNS"; then
     3405  if [ "$_ACME_IS_RENEW" = "1" ] && _hasfield "$Le_Webroot" "$W_DNS"; then
    33243406    _err "$_DNS_MANUAL_ERR"
    33253407  fi
     
    33533435
    33543436  #run renew hook
    3355   if [ "$IS_RENEW" ] && [ "$_chk_renew_hook" ]; then
     3437  if [ "$_ACME_IS_RENEW" ] && [ "$_chk_renew_hook" ]; then
    33563438    _info "Run renew hook:'$_chk_renew_hook'"
    33573439    if ! (
     
    33743456}
    33753457
     3458#account_key_length   eab-kid  eab-hmac-key
    33763459registeraccount() {
    3377   _reg_length="$1"
     3460  _account_key_length="$1"
     3461  _eab_id="$2"
     3462  _eab_hmac_key="$3"
    33783463  _initpath
    3379   _regAccount "$_reg_length"
     3464  _regAccount "$_account_key_length" "$_eab_id" "$_eab_hmac_key"
    33803465}
    33813466
     
    33863471__calc_account_thumbprint() {
    33873472  printf "%s" "$jwk" | tr -d ' ' | _digest "sha256" | _url_replace
     3473}
     3474
     3475_getAccountEmail() {
     3476  if [ "$ACCOUNT_EMAIL" ]; then
     3477    echo "$ACCOUNT_EMAIL"
     3478    return 0
     3479  fi
     3480  if [ -z "$CA_EMAIL" ]; then
     3481    CA_EMAIL="$(_readcaconf CA_EMAIL)"
     3482  fi
     3483  if [ "$CA_EMAIL" ]; then
     3484    echo "$CA_EMAIL"
     3485    return 0
     3486  fi
     3487  _readaccountconf "ACCOUNT_EMAIL"
    33883488}
    33893489
     
    33923492  _initpath
    33933493  _reg_length="$1"
     3494  _eab_id="$2"
     3495  _eab_hmac_key="$3"
    33943496  _debug3 _regAccount "$_regAccount"
    33953497  _initAPI
     
    34163518    return 1
    34173519  fi
    3418 
     3520  if [ "$_eab_id" ] && [ "$_eab_hmac_key" ]; then
     3521    _savecaconf CA_EAB_KEY_ID "$_eab_id"
     3522    _savecaconf CA_EAB_HMAC_KEY "$_eab_hmac_key"
     3523  fi
     3524  _eab_id=$(_readcaconf "CA_EAB_KEY_ID")
     3525  _eab_hmac_key=$(_readcaconf "CA_EAB_HMAC_KEY")
     3526  _secure_debug3 _eab_id "$_eab_id"
     3527  _secure_debug3 _eab_hmac_key "$_eab_hmac_key"
     3528  _email="$(_getAccountEmail)"
     3529  if [ "$_email" ]; then
     3530    _savecaconf "CA_EMAIL" "$_email"
     3531  fi
    34193532  if [ "$ACME_VERSION" = "2" ]; then
    3420     regjson='{"termsOfServiceAgreed": true}'
    3421     if [ "$ACCOUNT_EMAIL" ]; then
    3422       regjson='{"contact": ["mailto: '$ACCOUNT_EMAIL'"], "termsOfServiceAgreed": true}'
    3423     fi
     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}"
    34243587  else
    34253588    _reg_res="$ACME_NEW_ACCOUNT_RES"
    34263589    regjson='{"resource": "'$_reg_res'", "terms-of-service-agreed": true, "agreement": "'$ACME_AGREEMENT'"}'
    3427     if [ "$ACCOUNT_EMAIL" ]; then
    3428       regjson='{"resource": "'$_reg_res'", "contact": ["mailto: '$ACCOUNT_EMAIL'"], "terms-of-service-agreed": true, "agreement": "'$ACME_AGREEMENT'"}'
    3429     fi
    3430   fi
    3431 
    3432   _info "Registering account"
     3590    if [ "$_email" ]; then
     3591      regjson='{"resource": "'$_reg_res'", "contact": ["mailto:'$_email'"], "terms-of-service-agreed": true, "agreement": "'$ACME_AGREEMENT'"}'
     3592    fi
     3593  fi
     3594
     3595  _info "Registering account: $ACME_DIRECTORY"
    34333596
    34343597  if ! _send_signed_request "${ACME_NEW_ACCOUNT}" "$regjson"; then
     
    34373600  fi
    34383601
     3602  _eabAlreadyBound=""
    34393603  if [ "$code" = "" ] || [ "$code" = '201' ]; then
    34403604    echo "$response" >"$ACCOUNT_JSON_PATH"
     
    34423606  elif [ "$code" = '409' ] || [ "$code" = '200' ]; then
    34433607    _info "Already registered"
     3608  elif [ "$code" = '400' ] && _contains "$response" 'The account is not awaiting external account binding'; then
     3609    _info "Already register EAB."
     3610    _eabAlreadyBound=1
    34443611  else
    34453612    _err "Register account Error: $response"
     
    34473614  fi
    34483615
    3449   _debug2 responseHeaders "$responseHeaders"
    3450   _accUri="$(echo "$responseHeaders" | grep -i "^Location:" | _head_n 1 | cut -d ':' -f 2- | tr -d "\r\n ")"
    3451   _debug "_accUri" "$_accUri"
    3452   if [ -z "$_accUri" ]; then
    3453     _err "Can not find account id url."
    3454     _err "$responseHeaders"
    3455     return 1
    3456   fi
    3457   _savecaconf "ACCOUNT_URL" "$_accUri"
     3616  if [ -z "$_eabAlreadyBound" ]; then
     3617    _debug2 responseHeaders "$responseHeaders"
     3618    _accUri="$(echo "$responseHeaders" | grep -i "^Location:" | _head_n 1 | cut -d ':' -f 2- | tr -d "\r\n ")"
     3619    _debug "_accUri" "$_accUri"
     3620    if [ -z "$_accUri" ]; then
     3621      _err "Can not find account id url."
     3622      _err "$responseHeaders"
     3623      return 1
     3624    fi
     3625    _savecaconf "ACCOUNT_URL" "$_accUri"
     3626  else
     3627    ACCOUNT_URL="$(_readcaconf ACCOUNT_URL)"
     3628  fi
    34583629  export ACCOUNT_URL="$_accUri"
    34593630
     
    35043675  _initAPI
    35053676
     3677  _email="$(_getAccountEmail)"
    35063678  if [ "$ACME_VERSION" = "2" ]; then
    35073679    if [ "$ACCOUNT_EMAIL" ]; then
    3508       updjson='{"contact": ["mailto: '$ACCOUNT_EMAIL'"]}'
     3680      updjson='{"contact": ["mailto:'$_email'"]}'
     3681    else
     3682      updjson='{"contact": []}'
    35093683    fi
    35103684  else
     
    35193693
    35203694  if [ "$code" = '200' ]; then
     3695    echo "$response" >"$ACCOUNT_JSON_PATH"
    35213696    _info "account update success for $_accUri."
    35223697  else
     
    38304005}
    38314006
     4007#file
     4008_get_cert_issuers() {
     4009  _cfile="$1"
     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
     4014  fi
     4015}
     4016
     4017#cert  issuer
     4018_match_issuer() {
     4019  _cfile="$1"
     4020  _missuer="$2"
     4021  _fissuers="$(_get_cert_issuers $_cfile)"
     4022  _debug2 _fissuers "$_fissuers"
     4023  if _contains "$_fissuers" "$_missuer"; then
     4024    return 0
     4025  fi
     4026  _fissuers="$(echo "$_fissuers" | _lower_case)"
     4027  _missuer="$(echo "$_missuer" | _lower_case)"
     4028  _contains "$_fissuers" "$_missuer"
     4029}
     4030
    38324031#webroot, domain domainlist  keylength
    38334032issue() {
    38344033  if [ -z "$2" ]; then
    3835     _usage "Usage: $PROJECT_ENTRY --issue  -d  a.com  -w /path/to/webroot/a.com/ "
     4034    _usage "Usage: $PROJECT_ENTRY --issue --domain <domain.tld> --webroot <directory>"
    38364035    return 1
    38374036  fi
     
    38624061  _local_addr="${13}"
    38634062  _challenge_alias="${14}"
    3864   #remove these later.
    3865   if [ "$_web_roots" = "dns-cf" ]; then
    3866     _web_roots="dns_cf"
    3867   fi
    3868   if [ "$_web_roots" = "dns-dp" ]; then
    3869     _web_roots="dns_dp"
    3870   fi
    3871   if [ "$_web_roots" = "dns-cx" ]; then
    3872     _web_roots="dns_cx"
    3873   fi
    3874 
    3875   if [ ! "$IS_RENEW" ]; then
     4063  _preferred_chain="${15}"
     4064
     4065  if [ -z "$_ACME_IS_RENEW" ]; then
    38764066    _initpath "$_main_domain" "$_key_length"
    38774067    mkdir -p "$DOMAIN_PATH"
     
    39244114    _cleardomainconf "Le_ChallengeAlias"
    39254115  fi
    3926 
    3927   if [ "$ACME_DIRECTORY" != "$DEFAULT_CA" ]; then
    3928     Le_API="$ACME_DIRECTORY"
    3929     _savedomainconf "Le_API" "$Le_API"
    3930   else
    3931     _cleardomainconf Le_API
    3932   fi
    3933 
     4116  if [ "$_preferred_chain" ]; then
     4117    _savedomainconf "Le_Preferred_Chain" "$_preferred_chain" "base64"
     4118  else
     4119    _cleardomainconf "Le_Preferred_Chain"
     4120  fi
     4121
     4122  Le_API="$ACME_DIRECTORY"
     4123  _savedomainconf "Le_API" "$Le_API"
     4124
     4125  _info "Using CA: $ACME_DIRECTORY"
    39344126  if [ "$_alt_domains" = "$NO_VALUE" ]; then
    39354127    _alt_domains=""
     
    40214213      _savedomainconf "Le_OrderFinalize" "$Le_OrderFinalize"
    40224214
    4023       _authorizations_seg="$(echo "$response" | _egrep_o '"authorizations" *: *\[[^\]*\]' | cut -d '[' -f 2 | tr -d ']' | tr -d '"')"
     4215      _authorizations_seg="$(echo "$response" | _json_decode | _egrep_o '"authorizations" *: *\[[^\[]*\]' | cut -d '[' -f 2 | tr -d ']' | tr -d '"')"
    40244216      _debug2 _authorizations_seg "$_authorizations_seg"
    40254217      if [ -z "$_authorizations_seg" ]; then
     
    40874279      if [ "$ACME_VERSION" = "2" ]; then
    40884280        _idn_d="$(_idn "$d")"
    4089         _candindates="$(echo "$_authorizations_map" | grep -i "^$_idn_d,")"
    4090         _debug2 _candindates "$_candindates"
    4091         if [ "$(echo "$_candindates" | wc -l)" -gt 1 ]; then
    4092           for _can in $_candindates; do
     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
    40934285            if _startswith "$(echo "$_can" | tr '.' '|')" "$(echo "$_idn_d" | tr '.' '|'),"; then
    4094               _candindates="$_can"
     4286              _candidates="$_can"
    40954287              break
    40964288            fi
    40974289          done
    40984290        fi
    4099         response="$(echo "$_candindates" | sed "s/$_idn_d,//")"
     4291        response="$(echo "$_candidates" | sed "s/$_idn_d,//")"
    41004292        _debug2 "response" "$response"
    41014293        if [ -z "$response" ]; then
     
    42884480  if [ "$dns_entries" ]; then
    42894481    if [ -z "$Le_DNSSleep" ]; then
    4290       _info "Let's check each dns records now. Sleep 20 seconds first."
     4482      _info "Let's check each DNS record now. Sleep 20 seconds first."
    42914483      _sleep 20
    42924484      if ! _check_dns_entries; then
     
    45234715
    45244716  if [ "$ACME_VERSION" = "2" ]; then
    4525     _info "Lets finalize the order, Le_OrderFinalize: $Le_OrderFinalize"
     4717    _info "Lets finalize the order."
     4718    _info "Le_OrderFinalize" "$Le_OrderFinalize"
    45264719    if ! _send_signed_request "${Le_OrderFinalize}" "{\"csr\": \"$der\"}"; then
    45274720      _err "Sign failed."
     
    45364729    fi
    45374730    if [ -z "$Le_LinkOrder" ]; then
    4538       Le_LinkOrder="$(echo "$responseHeaders" | grep -i '^Location.*$' | _tail_n 1 | tr -d "\r\n" | cut -d ":" -f 2-)"
     4731      Le_LinkOrder="$(echo "$responseHeaders" | grep -i '^Location.*$' | _tail_n 1 | tr -d "\r\n \t" | cut -d ":" -f 2-)"
    45394732    fi
    45404733
     
    45424735
    45434736    _link_cert_retry=0
    4544     _MAX_CERT_RETRY=5
     4737    _MAX_CERT_RETRY=30
    45454738    while [ "$_link_cert_retry" -lt "$_MAX_CERT_RETRY" ]; do
    45464739      if _contains "$response" "\"status\":\"valid\""; then
     
    45574750      elif _contains "$response" "\"processing\""; then
    45584751        _info "Order status is processing, lets sleep and retry."
    4559         _sleep 2
     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
    45604760      else
    45614761        _err "Sign error, wrong status"
     
    45874787      return 1
    45884788    fi
    4589     _info "Download cert, Le_LinkCert: $Le_LinkCert"
     4789    _info "Downloading cert."
     4790    _info "Le_LinkCert" "$Le_LinkCert"
    45904791    if ! _send_signed_request "$Le_LinkCert"; then
    45914792      _err "Sign failed, can not download cert:$Le_LinkCert."
     
    45964797
    45974798    echo "$response" >"$CERT_PATH"
    4598 
    4599     if [ "$(grep -- "$BEGIN_CERT" "$CERT_PATH" | wc -l)" -gt "1" ]; then
    4600       _debug "Found cert chain"
    4601       cat "$CERT_PATH" >"$CERT_FULLCHAIN_PATH"
    4602       _end_n="$(grep -n -- "$END_CERT" "$CERT_FULLCHAIN_PATH" | _head_n 1 | cut -d : -f 1)"
    4603       _debug _end_n "$_end_n"
    4604       sed -n "1,${_end_n}p" "$CERT_FULLCHAIN_PATH" >"$CERT_PATH"
    4605       _end_n="$(_math $_end_n + 1)"
    4606       sed -n "${_end_n},9999p" "$CERT_FULLCHAIN_PATH" >"$CA_CERT_PATH"
    4607     fi
    4608 
     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
    46094827  else
    46104828    if ! _send_signed_request "${ACME_NEW_ORDER}" "{\"resource\": \"$ACME_NEW_ORDER_RES\", \"csr\": \"$der\"}" "needbase64"; then
     
    46504868    fi
    46514869
    4652     if [ ! "$USER_PATH" ] || [ ! "$ACME_IN_CRON" ]; then
     4870    if [ ! "$USER_PATH" ] || [ ! "$_ACME_IN_CRON" ]; then
    46534871      USER_PATH="$PATH"
    46544872      _saveaccountconf "USER_PATH" "$USER_PATH"
     
    47754993}
    47764994
     4995#in_out_cert   out_fullchain   out_ca
     4996_split_cert_chain() {
     4997  _certf="$1"
     4998  _fullchainf="$2"
     4999  _caf="$3"
     5000  if [ "$(grep -- "$BEGIN_CERT" "$_certf" | wc -l)" -gt "1" ]; then
     5001    _debug "Found cert chain"
     5002    cat "$_certf" >"$_fullchainf"
     5003    _end_n="$(grep -n -- "$END_CERT" "$_fullchainf" | _head_n 1 | cut -d : -f 1)"
     5004    _debug _end_n "$_end_n"
     5005    sed -n "1,${_end_n}p" "$_fullchainf" >"$_certf"
     5006    _end_n="$(_math $_end_n + 1)"
     5007    sed -n "${_end_n},9999p" "$_fullchainf" >"$_caf"
     5008  fi
     5009}
     5010
    47775011#domain  [isEcc]
    47785012renew() {
    47795013  Le_Domain="$1"
    47805014  if [ -z "$Le_Domain" ]; then
    4781     _usage "Usage: $PROJECT_ENTRY --renew  -d domain.com [--ecc]"
     5015    _usage "Usage: $PROJECT_ENTRY --renew --domain <domain.tld> [--ecc]"
    47825016    return 1
    47835017  fi
     
    47895023  _info "$(__green "Renew: '$Le_Domain'")"
    47905024  if [ ! -f "$DOMAIN_CONF" ]; then
    4791     _info "'$Le_Domain' is not a issued domain, skip."
     5025    _info "'$Le_Domain' is not an issued domain, skip."
    47925026    return $RENEW_SKIP
    47935027  fi
     
    48105044
    48115045  if [ "$Le_API" ]; then
    4812     if [ "$_OLD_CA_HOST" = "$Le_API" ]; then
    4813       export Le_API="$DEFAULT_CA"
    4814       _savedomainconf Le_API "$Le_API"
    4815     fi
    4816     if [ "$_OLD_STAGE_CA_HOST" = "$Le_API" ]; then
    4817       export Le_API="$DEFAULT_STAGING_CA"
    4818       _savedomainconf Le_API "$Le_API"
    4819     fi
    48205046    export ACME_DIRECTORY="$Le_API"
    48215047    #reload ca configs
     
    48335059  fi
    48345060
    4835   if [ "$ACME_IN_CRON" = "1" ] && [ -z "$Le_CertCreateTime" ]; then
     5061  if [ "$_ACME_IN_CRON" = "1" ] && [ -z "$Le_CertCreateTime" ]; then
    48365062    _info "Skip invalid cert for: $Le_Domain"
    48375063    return $RENEW_SKIP
    48385064  fi
    48395065
    4840   IS_RENEW="1"
     5066  _ACME_IS_RENEW="1"
    48415067  Le_ReloadCmd="$(_readdomainconf Le_ReloadCmd)"
    48425068  Le_PreHook="$(_readdomainconf Le_PreHook)"
    48435069  Le_PostHook="$(_readdomainconf Le_PostHook)"
    48445070  Le_RenewHook="$(_readdomainconf Le_RenewHook)"
    4845   issue "$Le_Webroot" "$Le_Domain" "$Le_Alt" "$Le_Keylength" "$Le_RealCertPath" "$Le_RealKeyPath" "$Le_RealCACertPath" "$Le_ReloadCmd" "$Le_RealFullChainPath" "$Le_PreHook" "$Le_PostHook" "$Le_RenewHook" "$Le_LocalAddress" "$Le_ChallengeAlias"
     5071  Le_Preferred_Chain="$(_readdomainconf Le_Preferred_Chain)"
     5072  issue "$Le_Webroot" "$Le_Domain" "$Le_Alt" "$Le_Keylength" "$Le_RealCertPath" "$Le_RealKeyPath" "$Le_RealCACertPath" "$Le_ReloadCmd" "$Le_RealFullChainPath" "$Le_PreHook" "$Le_PostHook" "$Le_RenewHook" "$Le_LocalAddress" "$Le_ChallengeAlias" "$Le_Preferred_Chain"
    48465073  res="$?"
    48475074  if [ "$res" != "0" ]; then
     
    48545081  fi
    48555082
    4856   IS_RENEW=""
     5083  _ACME_IS_RENEW=""
    48575084
    48585085  return "$res"
     
    48755102    _debug di "$di"
    48765103    if ! [ -d "$di" ]; then
    4877       _debug "Not directory, skip: $di"
     5104      _debug "Not a directory, skip: $di"
    48785105      continue
    48795106    fi
     
    48945121        _notify_code=0
    48955122      fi
    4896       if [ "$ACME_IN_CRON" ]; then
     5123      if [ "$_ACME_IN_CRON" ]; then
    48975124        if [ $_set_level -ge $NOTIFY_LEVEL_RENEW ]; then
    48985125          if [ "$NOTIFY_MODE" = "$NOTIFY_MODE_CERT" ]; then
     
    49085135        _notify_code=$RENEW_SKIP
    49095136      fi
    4910       if [ "$ACME_IN_CRON" ]; then
     5137      if [ "$_ACME_IN_CRON" ]; then
    49115138        if [ $_set_level -ge $NOTIFY_LEVEL_SKIP ]; then
    49125139          if [ "$NOTIFY_MODE" = "$NOTIFY_MODE_CERT" ]; then
     
    49235150        _notify_code=1
    49245151      fi
    4925       if [ "$ACME_IN_CRON" ]; then
     5152      if [ "$_ACME_IN_CRON" ]; then
    49265153        if [ $_set_level -ge $NOTIFY_LEVEL_ERROR ]; then
    49275154          if [ "$NOTIFY_MODE" = "$NOTIFY_MODE_CERT" ]; then
     
    49445171  _debug _error_level "$_error_level"
    49455172  _debug _set_level "$_set_level"
    4946   if [ "$ACME_IN_CRON" ] && [ $_error_level -le $_set_level ]; then
     5173  if [ "$_ACME_IN_CRON" ] && [ $_error_level -le $_set_level ]; then
    49475174    if [ -z "$NOTIFY_MODE" ] || [ "$NOTIFY_MODE" = "$NOTIFY_MODE_BULK" ]; then
    49485175      _msg_subject="Renew"
     
    49785205  _csrW="$2"
    49795206  if [ -z "$_csrfile" ] || [ -z "$_csrW" ]; then
    4980     _usage "Usage: $PROJECT_ENTRY --signcsr  --csr mycsr.csr  -w /path/to/webroot/a.com/ "
     5207    _usage "Usage: $PROJECT_ENTRY --sign-csr --csr <csr-file> --webroot <directory>"
    49815208    return 1
    49825209  fi
     
    50465273  _csrd="$2"
    50475274  if [ -z "$_csrfile" ] && [ -z "$_csrd" ]; then
    5048     _usage "Usage: $PROJECT_ENTRY --showcsr  --csr mycsr.csr"
     5275    _usage "Usage: $PROJECT_ENTRY --show-csr --csr <csr-file>"
    50495276    return 1
    50505277  fi
     
    50775304}
    50785305
     5306#listraw  domain
    50795307list() {
    50805308  _raw="$1"
     5309  _domain="$2"
    50815310  _initpath
    50825311
    50835312  _sep="|"
    50845313  if [ "$_raw" ]; then
    5085     printf "%s\n" "Main_Domain${_sep}KeyLength${_sep}SAN_Domains${_sep}Created${_sep}Renew"
     5314    if [ -z "$_domain" ]; then
     5315      printf "%s\n" "Main_Domain${_sep}KeyLength${_sep}SAN_Domains${_sep}CA${_sep}Created${_sep}Renew"
     5316    fi
    50865317    for di in "${CERT_HOME}"/*.*/; do
    50875318      d=$(basename "$di")
     
    50955326        if [ -f "$DOMAIN_CONF" ]; then
    50965327          . "$DOMAIN_CONF"
    5097           printf "%s\n" "$Le_Domain${_sep}\"$Le_Keylength\"${_sep}$Le_Alt${_sep}$Le_CertCreateTimeStr${_sep}$Le_NextRenewTimeStr"
     5328          _ca="$(_getCAShortName "$Le_API")"
     5329          if [ -z "$_domain" ]; then
     5330            printf "%s\n" "$Le_Domain${_sep}\"$Le_Keylength\"${_sep}$Le_Alt${_sep}$_ca${_sep}$Le_CertCreateTimeStr${_sep}$Le_NextRenewTimeStr"
     5331          else
     5332            if [ "$_domain" = "$d" ]; then
     5333              cat "$DOMAIN_CONF"
     5334            fi
     5335          fi
    50985336        fi
    50995337      )
     
    51015339  else
    51025340    if _exists column; then
    5103       list "raw" | column -t -s "$_sep"
     5341      list "raw" "$_domain" | column -t -s "$_sep"
    51045342    else
    5105       list "raw" | tr "$_sep" '\t'
     5343      list "raw" "$_domain" | tr "$_sep" '\t'
    51065344    fi
    51075345  fi
     
    51525390  _isEcc="$3"
    51535391  if [ -z "$_hooks" ]; then
    5154     _usage "Usage: $PROJECT_ENTRY --deploy -d domain.com --deploy-hook cpanel [--ecc] "
     5392    _usage "Usage: $PROJECT_ENTRY --deploy --domain <domain.tld> --deploy-hook <hookname> [--ecc] "
    51555393    return 1
    51565394  fi
     
    51735411  _main_domain="$1"
    51745412  if [ -z "$_main_domain" ]; then
    5175     _usage "Usage: $PROJECT_ENTRY --installcert -d domain.com  [--ecc] [--cert-file cert-file-path]  [--key-file key-file-path]  [--ca-file ca-cert-file-path]   [ --reloadCmd reloadCmd] [--fullchain-file fullchain-path]"
     5413    _usage "Usage: $PROJECT_ENTRY --install-cert --domain <domain.tld> [--ecc] [--cert-file <file>] [--key-file <file>] [--ca-file <file>] [ --reloadcmd <command>] [--fullchain-file <file>]"
    51765414    return 1
    51775415  fi
     
    52315469  if [ "$_real_cert" ]; then
    52325470    _info "Installing cert to:$_real_cert"
    5233     if [ -f "$_real_cert" ] && [ ! "$IS_RENEW" ]; then
     5471    if [ -f "$_real_cert" ] && [ ! "$_ACME_IS_RENEW" ]; then
    52345472      cp "$_real_cert" "$_backup_path/cert.bak"
    52355473    fi
     
    52435481      cat "$CA_CERT_PATH" >>"$_real_ca" || return 1
    52445482    else
    5245       if [ -f "$_real_ca" ] && [ ! "$IS_RENEW" ]; then
     5483      if [ -f "$_real_ca" ] && [ ! "$_ACME_IS_RENEW" ]; then
    52465484        cp "$_real_ca" "$_backup_path/ca.bak"
    52475485      fi
     
    52525490  if [ "$_real_key" ]; then
    52535491    _info "Installing key to:$_real_key"
    5254     if [ -f "$_real_key" ] && [ ! "$IS_RENEW" ]; then
     5492    if [ -f "$_real_key" ] && [ ! "$_ACME_IS_RENEW" ]; then
    52555493      cp "$_real_key" "$_backup_path/key.bak"
    52565494    fi
     
    52655503  if [ "$_real_fullchain" ]; then
    52665504    _info "Installing full chain to:$_real_fullchain"
    5267     if [ -f "$_real_fullchain" ] && [ ! "$IS_RENEW" ]; then
     5505    if [ -f "$_real_fullchain" ] && [ ! "$_ACME_IS_RENEW" ]; then
    52685506      cp "$_real_fullchain" "$_backup_path/fullchain.bak"
    52695507    fi
     
    54485686}
    54495687
     5688#domain  isECC  revokeReason
    54505689revoke() {
    54515690  Le_Domain="$1"
    54525691  if [ -z "$Le_Domain" ]; then
    5453     _usage "Usage: $PROJECT_ENTRY --revoke -d domain.com [--ecc]"
     5692    _usage "Usage: $PROJECT_ENTRY --revoke --domain <domain.tld> [--ecc]"
    54545693    return 1
    54555694  fi
    54565695
    54575696  _isEcc="$2"
    5458 
     5697  _reason="$3"
     5698  if [ -z "$_reason" ]; then
     5699    _reason="0"
     5700  fi
    54595701  _initpath "$Le_Domain" "$_isEcc"
    54605702  if [ ! -f "$DOMAIN_CONF" ]; then
     
    54785720
    54795721  if [ "$ACME_VERSION" = "2" ]; then
    5480     data="{\"certificate\": \"$cert\"}"
     5722    data="{\"certificate\": \"$cert\",\"reason\":$_reason}"
    54815723  else
    54825724    data="{\"resource\": \"revoke-cert\", \"certificate\": \"$cert\"}"
     
    54975739    fi
    54985740  else
    5499     _info "Domain key file doesn't exists."
     5741    _info "Domain key file doesn't exist."
    55005742  fi
    55015743
     
    55195761  Le_Domain="$1"
    55205762  if [ -z "$Le_Domain" ]; then
    5521     _usage "Usage: $PROJECT_ENTRY --remove -d domain.com [--ecc]"
     5763    _usage "Usage: $PROJECT_ENTRY --remove --domain <domain.tld> [--ecc]"
    55225764    return 1
    55235765  fi
     
    55965838  fi
    55975839
    5598   entries="$(echo "$response" | _egrep_o "{ *\"type\":\"[^\"]*\", *\"status\": *\"valid\", *\"$_URL_NAME\"[^}]*")"
     5840  entries="$(echo "$response" | tr '][' '==' | _egrep_o "challenges\": *=[^=]*=" | tr '}{' '\n' | grep "\"status\": *\"valid\"")"
    55995841  if [ -z "$entries" ]; then
    56005842    _info "No valid entries found."
     
    56395881    _info "Found $_vtype"
    56405882
    5641     uri="$(echo "$entry" | _egrep_o "\"$_URL_NAME\":\"[^\"]*" | cut -d : -f 2,3 | tr -d '"')"
     5883    uri="$(echo "$entry" | _egrep_o "\"$_URL_NAME\":\"[^\"]*\"" | tr -d '" ' | cut -d : -f 2-)"
    56425884    _debug uri "$uri"
    56435885
     
    56795921  _debug _d_domain_list "$_d_domain_list"
    56805922  if [ -z "$(echo $_d_domain_list | cut -d , -f 1)" ]; then
    5681     _usage "Usage: $PROJECT_ENTRY --deactivate -d domain.com [-d domain.com]"
     5923    _usage "Usage: $PROJECT_ENTRY --deactivate --domain <domain.tld> [--domain <domain2.tld> ...]"
    56825924    return 1
    56835925  fi
     
    58786120  fi
    58796121
    5880   if [ "$ACME_IN_CRON" != "1" ]; then
     6122  if [ "$_ACME_IN_CRON" != "1" ]; then
    58816123    if ! _precheck "$_nocron"; then
    58826124      _err "Pre-check failed, can not install."
     
    59356177  _info "Installed to $LE_WORKING_DIR/$PROJECT_ENTRY"
    59366178
    5937   if [ "$ACME_IN_CRON" != "1" ] && [ -z "$_noprofile" ]; then
     6179  if [ "$_ACME_IN_CRON" != "1" ] && [ -z "$_noprofile" ]; then
    59386180    _installalias "$_c_home"
    59396181  fi
     
    60336275
    60346276cron() {
    6035   export ACME_IN_CRON=1
     6277  export _ACME_IN_CRON=1
    60366278  _initpath
    60376279  _info "$(__green "===Starting cron===")"
     
    60546296  renewAll
    60556297  _ret="$?"
    6056   ACME_IN_CRON=""
     6298  _ACME_IN_CRON=""
    60576299  _info "$(__green "===End cron===")"
    60586300  exit $_ret
     
    61396381
    61406382  if [ -z "$_nhook$_nlevel$_nmode" ]; then
    6141     _usage "Usage: $PROJECT_ENTRY --set-notify [--notify-hook mailgun] [--notify-level $NOTIFY_LEVEL_DEFAULT] [--notify-mode $NOTIFY_MODE_DEFAULT]"
     6383    _usage "Usage: $PROJECT_ENTRY --set-notify [--notify-hook <hookname>] [--notify-level <0|1|2|3>] [--notify-mode <0|1>]"
    61426384    _usage "$_NOTIFY_WIKI"
    61436385    return 1
     
    61786420  _initpath
    61796421  version
    6180   echo "Usage: $PROJECT_ENTRY  command ...[parameters]....
     6422  echo "Usage: $PROJECT_ENTRY <command> ... [parameters ...]
    61816423Commands:
    6182   --help, -h               Show this help message.
    6183   --version, -v            Show version info.
     6424  -h, --help               Show this help message.
     6425  -v, --version            Show version info.
    61846426  --install                Install $PROJECT_NAME to your system.
    61856427  --uninstall              Uninstall $PROJECT_NAME, and uninstall the cron job.
    61866428  --upgrade                Upgrade $PROJECT_NAME to the latest code from $PROJECT.
    61876429  --issue                  Issue a cert.
    6188   --signcsr                Issue a cert from an existing csr.
    61896430  --deploy                 Deploy the cert to your server.
    6190   --install-cert           Install the issued cert to apache/nginx or any other server.
    6191   --renew, -r              Renew a cert.
     6431  -i, --install-cert       Install the issued cert to apache/nginx or any other server.
     6432  -r, --renew              Renew a cert.
    61926433  --renew-all              Renew all the certs.
    61936434  --revoke                 Revoke a cert.
    61946435  --remove                 Remove the cert from list of certs known to $PROJECT_NAME.
    61956436  --list                   List all the certs.
    6196   --showcsr                Show the content of a csr.
    6197   --install-cronjob        Install the cron job to renew certs, you don't need to call this. The 'install' command can automatically install the cron job.
    6198   --uninstall-cronjob      Uninstall the cron job. The 'uninstall' command can do this automatically.
    6199   --cron                   Run cron job to renew all the certs.
    6200   --toPkcs                 Export the certificate and key to a pfx file.
    6201   --toPkcs8                Convert to pkcs8 format.
     6437  --to-pkcs12              Export the certificate and key to a pfx file.
     6438  --to-pkcs8               Convert to pkcs8 format.
     6439  --sign-csr               Issue a cert from an existing csr.
     6440  --show-csr               Show the content of a csr.
     6441  -ccr, --create-csr       Create CSR, professional use.
     6442  --create-domain-key      Create an domain private key, professional use.
    62026443  --update-account         Update account info.
    62036444  --register-account       Register account key.
    62046445  --deactivate-account     Deactivate the account.
    62056446  --create-account-key     Create an account private key, professional use.
    6206   --create-domain-key      Create an domain private key, professional use.
    6207   --createCSR, -ccsr       Create CSR , professional use.
     6447  --install-cronjob        Install the cron job to renew certs, you don't need to call this. The 'install' command can automatically install the cron job.
     6448  --uninstall-cronjob      Uninstall the cron job. The 'uninstall' command can do this automatically.
     6449  --cron                   Run cron job to renew all the certs.
     6450  --set-notify             Set the cron notification hook, level or mode.
    62086451  --deactivate             Deactivate the domain authz, professional use.
    6209   --set-notify             Set the cron notification hook, level or mode.
     6452  --set-default-ca         Used with '--server', Set the default CA to use.
     6453                           See: $_SERVER_WIKI
    62106454
    62116455
    62126456Parameters:
    6213   --domain, -d   domain.tld         Specifies a domain, used to issue, renew or revoke etc.
    6214   --challenge-alias domain.tld      The challenge domain alias for DNS alias mode: $_DNS_ALIAS_WIKI
    6215   --domain-alias domain.tld         The domain alias for DNS alias mode: $_DNS_ALIAS_WIKI
    6216   --force, -f                       Used to force to install or force to renew a cert immediately.
    6217   --staging, --test                 Use staging server, just for test.
    6218   --debug                           Output debug info.
    6219   --output-insecure                 Output all the sensitive messages. By default all the credentials/sensitive messages are hidden from the output/debug/log for security.
    6220   --webroot, -w  /path/to/webroot   Specifies the web root folder for web root mode.
     6457  -d, --domain <domain.tld>         Specifies a domain, used to issue, renew or revoke etc.
     6458  --challenge-alias <domain.tld>    The challenge domain alias for DNS alias mode.
     6459                                    See: $_DNS_ALIAS_WIKI
     6460
     6461  --domain-alias <domain.tld>       The domain alias for DNS alias mode.
     6462                                    See: $_DNS_ALIAS_WIKI
     6463
     6464  --preferred-chain <chain>         If the CA offers multiple certificate chains, prefer the chain with an issuer matching this Subject Common Name.
     6465                                    If no match, the default offered chain will be used. (default: empty)
     6466                                    See: $_PREFERRED_CHAIN_WIKI
     6467
     6468  -f, --force                       Force install, force cert renewal or override sudo restrictions.
     6469  --staging, --test                 Use staging server, for testing.
     6470  --debug [0|1|2|3]                 Output debug info. Defaults to 1 if argument is omitted.
     6471  --output-insecure                 Output all the sensitive messages.
     6472                                    By default all the credentials/sensitive messages are hidden from the output/debug/log for security.
     6473  -w, --webroot <directory>         Specifies the web root folder for web root mode.
    62216474  --standalone                      Use standalone mode.
    62226475  --alpn                            Use standalone alpn mode.
    6223   --stateless                       Use stateless mode, see: $_STATELESS_WIKI
     6476  --stateless                       Use stateless mode.
     6477                                    See: $_STATELESS_WIKI
     6478
    62246479  --apache                          Use apache mode.
    6225   --dns [dns_cf|dns_dp|dns_cx|/path/to/api/file]   Use dns mode or dns api.
    6226   --dnssleep  [$DEFAULT_DNS_SLEEP]                  The time in seconds to wait for all the txt records to take effect in dns api mode. Default $DEFAULT_DNS_SLEEP seconds.
    6227 
    6228   --keylength, -k [2048]            Specifies the domain key length: 2048, 3072, 4096, 8192 or ec-256, ec-384, ec-521.
    6229   --accountkeylength, -ak [2048]    Specifies the account key length: 2048, 3072, 4096
    6230   --log    [/path/to/logfile]       Specifies the log file. The default is: \"$DEFAULT_LOG_FILE\" if you don't give a file path here.
    6231   --log-level 1|2                   Specifies the log level, default is 1.
    6232   --syslog [0|3|6|7]                Syslog level, 0: disable syslog, 3: error, 6: info, 7: debug.
     6480  --dns [dns_hook]                  Use dns manual mode or dns api. Defaults to manual mode when argument is omitted.
     6481                                    See: $_DNS_API_WIKI
     6482
     6483  --dnssleep <seconds>              The time in seconds to wait for all the txt records to propagate in dns api mode.
     6484                                    It's not necessary to use this by default, $PROJECT_NAME polls dns status by DOH automatically.
     6485  -k, --keylength <bits>            Specifies the domain key length: 2048, 3072, 4096, 8192 or ec-256, ec-384, ec-521.
     6486  -ak, --accountkeylength <bits>    Specifies the account key length: 2048, 3072, 4096
     6487  --log [file]                      Specifies the log file. Defaults to \"$DEFAULT_LOG_FILE\" if argument is omitted.
     6488  --log-level <1|2>                 Specifies the log level, default is 1.
     6489  --syslog <0|3|6|7>                Syslog level, 0: disable syslog, 3: error, 6: info, 7: debug.
     6490  --eab-kid <eab_key_id>            Key Identifier for External Account Binding.
     6491  --eab-hmac-key <eab_hmac_key>     HMAC key for External Account Binding.
     6492
    62336493
    62346494  These parameters are to install the cert to nginx/apache or any other server after issue/renew a cert:
    62356495
    6236   --cert-file                       After issue/renew, the cert will be copied to this path.
    6237   --key-file                        After issue/renew, the key will be copied to this path.
    6238   --ca-file                         After issue/renew, the intermediate cert will be copied to this path.
    6239   --fullchain-file                  After issue/renew, the fullchain cert will be copied to this path.
    6240 
    6241   --reloadcmd \"service nginx reload\" After issue/renew, it's used to reload the server.
    6242 
    6243   --server SERVER                   ACME Directory Resource URI. (default: $DEFAULT_CA)
    6244   --accountconf                     Specifies a customized account config file.
    6245   --home                            Specifies the home dir for $PROJECT_NAME.
    6246   --cert-home                       Specifies the home dir to save all the certs, only valid for '--install' command.
    6247   --config-home                     Specifies the home dir to save all the configurations.
    6248   --useragent                       Specifies the user agent string. it will be saved for future use too.
    6249   --accountemail                    Specifies the account email, only valid for the '--install' and '--update-account' command.
    6250   --accountkey                      Specifies the account key path, only valid for the '--install' command.
    6251   --days                            Specifies the days to renew the cert when using '--issue' command. The default value is $DEFAULT_RENEW days.
    6252   --httpport                        Specifies the standalone listening port. Only valid if the server is behind a reverse proxy or load balancer.
    6253   --tlsport                         Specifies the standalone tls listening port. Only valid if the server is behind a reverse proxy or load balancer.
    6254   --local-address                   Specifies the standalone/tls server listening address, in case you have multiple ip addresses.
     6496  --cert-file <file>                Path to copy the cert file to after issue/renew..
     6497  --key-file <file>                 Path to copy the key file to after issue/renew.
     6498  --ca-file <file>                  Path to copy the intermediate cert file to after issue/renew.
     6499  --fullchain-file <file>           Path to copy the fullchain cert file to after issue/renew.
     6500  --reloadcmd <command>             Command to execute after issue/renew to reload the server.
     6501
     6502  --server <server_uri>             ACME Directory Resource URI. (default: $DEFAULT_CA)
     6503                                    See: $_SERVER_WIKI
     6504
     6505  --accountconf <file>              Specifies a customized account config file.
     6506  --home <directory>                Specifies the home dir for $PROJECT_NAME.
     6507  --cert-home <directory>           Specifies the home dir to save all the certs, only valid for '--install' command.
     6508  --config-home <directory>         Specifies the home dir to save all the configurations.
     6509  --useragent <string>              Specifies the user agent string. it will be saved for future use too.
     6510  -m, --accountemail <email>        Specifies the account email, only valid for the '--install' and '--update-account' command.
     6511  --accountkey <file>               Specifies the account key path, only valid for the '--install' command.
     6512  --days <ndays>                    Specifies the days to renew the cert when using '--issue' command. The default value is $DEFAULT_RENEW days.
     6513  --httpport <port>                 Specifies the standalone listening port. Only valid if the server is behind a reverse proxy or load balancer.
     6514  --tlsport <port>                  Specifies the standalone tls listening port. Only valid if the server is behind a reverse proxy or load balancer.
     6515  --local-address <ip>              Specifies the standalone/tls server listening address, in case you have multiple ip addresses.
    62556516  --listraw                         Only used for '--list' command, list the certs in raw format.
    6256   --stopRenewOnError, -se           Only valid for '--renew-all' command. Stop if one cert has error in renewal.
     6517  -se, --stop-renew-on-error        Only valid for '--renew-all' command. Stop if one cert has error in renewal.
    62576518  --insecure                        Do not check the server certificate, in some devices, the api server's certificate may not be trusted.
    6258   --ca-bundle                       Specifies the path to the CA certificate bundle to verify api server's certificate.
    6259   --ca-path                         Specifies directory containing CA certificates in PEM format, used by wget or curl.
    6260   --nocron                          Only valid for '--install' command, which means: do not install the default cron job. In this case, the certs will not be renewed automatically.
     6519  --ca-bundle <file>                Specifies the path to the CA certificate bundle to verify api server's certificate.
     6520  --ca-path <directory>             Specifies directory containing CA certificates in PEM format, used by wget or curl.
     6521  --nocron                          Only valid for '--install' command, which means: do not install the default cron job.
     6522                                    In this case, the certs will not be renewed automatically.
    62616523  --noprofile                       Only valid for '--install' command, which means: do not install aliases to user profile.
    62626524  --no-color                        Do not output color text.
    62636525  --force-color                     Force output of color text. Useful for non-interactive use with the aha tool for HTML E-Mails.
    6264   --ecc                             Specifies to use the ECC cert. Valid for '--install-cert', '--renew', '--revoke', '--toPkcs' and '--createCSR'
    6265   --csr                             Specifies the input csr.
    6266   --pre-hook                        Command to be run before obtaining any certificates.
    6267   --post-hook                       Command to be run after attempting to obtain/renew certificates. No matter the obtain/renew is success or failed.
    6268   --renew-hook                      Command to be run once for each successfully renewed certificate.
    6269   --deploy-hook                     The hook file to deploy cert
    6270   --ocsp-must-staple, --ocsp        Generate ocsp must Staple extension.
    6271   --always-force-new-domain-key     Generate new domain key when renewal. Otherwise, the domain key is not changed by default.
    6272   --auto-upgrade   [0|1]            Valid for '--upgrade' command, indicating whether to upgrade automatically in future.
     6526  --ecc                             Specifies to use the ECC cert. Valid for '--install-cert', '--renew', '--revoke', '--to-pkcs12' and '--create-csr'
     6527  --csr <file>                      Specifies the input csr.
     6528  --pre-hook <command>              Command to be run before obtaining any certificates.
     6529  --post-hook <command>             Command to be run after attempting to obtain/renew certificates. Runs regardless of whether obtain/renew succeeded or failed.
     6530  --renew-hook <command>            Command to be run after each successfully renewed certificate.
     6531  --deploy-hook <hookname>          The hook file to deploy cert
     6532  --ocsp, --ocsp-must-staple        Generate OCSP-Must-Staple extension.
     6533  --always-force-new-domain-key     Generate new domain key on renewal. Otherwise, the domain key is not changed by default.
     6534  --auto-upgrade [0|1]              Valid for '--upgrade' command, indicating whether to upgrade automatically in future. Defaults to 1 if argument is omitted.
    62736535  --listen-v4                       Force standalone/tls server to listen at ipv4.
    62746536  --listen-v6                       Force standalone/tls server to listen at ipv6.
    6275   --openssl-bin                     Specifies a custom openssl bin location.
     6537  --openssl-bin <file>              Specifies a custom openssl bin location.
    62766538  --use-wget                        Force to use wget, if you have both curl and wget installed.
    6277   --yes-I-know-dns-manual-mode-enough-go-ahead-please  Force to use dns manual mode: $_DNS_MANUAL_WIKI
    6278   --branch, -b                      Only valid for '--upgrade' command, specifies the branch name to upgrade to.
    6279 
    6280   --notify-level  0|1|2|3           Set the notification level:  Default value is $NOTIFY_LEVEL_DEFAULT.
    6281                                      0: disabled, no notification will be sent.
    6282                                      1: send notifications only when there is an error.
    6283                                      2: send notifications when a cert is successfully renewed, or there is an error.
    6284                                      3: send notifications when a cert is skipped, renewed, or error.
    6285   --notify-mode   0|1               Set notification mode. Default value is $NOTIFY_MODE_DEFAULT.
    6286                                      0: Bulk mode. Send all the domain's notifications in one message(mail).
    6287                                      1: Cert mode. Send a message for every single cert.
    6288   --notify-hook   [hookname]        Set the notify hook
     6539  --yes-I-know-dns-manual-mode-enough-go-ahead-please  Force use of dns manual mode.
     6540                                    See:  $_DNS_MANUAL_WIKI
     6541
     6542  -b, --branch <branch>             Only valid for '--upgrade' command, specifies the branch name to upgrade to.
     6543  --notify-level <0|1|2|3>          Set the notification level:  Default value is $NOTIFY_LEVEL_DEFAULT.
     6544                                    0: disabled, no notification will be sent.
     6545                                    1: send notifications only when there is an error.
     6546                                    2: send notifications when a cert is successfully renewed, or there is an error.
     6547                                    3: send notifications when a cert is skipped, renewed, or error.
     6548  --notify-mode <0|1>               Set notification mode. Default value is $NOTIFY_MODE_DEFAULT.
     6549                                    0: Bulk mode. Send all the domain's notifications in one message(mail).
     6550                                    1: Cert mode. Send a message for every single cert.
     6551  --notify-hook <hookname>          Set the notify hook
     6552  --revoke-reason <0-10>            The reason for revocation, can be used in conjunction with the '--revoke' command.
     6553                                    See: $_REVOKE_WIKI
     6554
     6555  --password <password>             Add a password to exported pfx file. Use with --to-pkcs12.
     6556
    62896557
    62906558"
     
    63196587      _info "Install success!"
    63206588      _initpath
    6321       _saveaccountconf "UPGRADE_HASH" "$(_getMasterHash)"
     6589      _saveaccountconf "UPGRADE_HASH" "$(_getUpgradeHash)"
    63226590    fi
    63236591
     
    63296597}
    63306598
    6331 _getMasterHash() {
     6599_getRepoHash() {
     6600  _hash_path=$1
     6601  shift
     6602  _hash_url="https://api.github.com/repos/acmesh-official/$PROJECT_NAME/git/refs/$_hash_path"
     6603  _get $_hash_url | tr -d "\r\n" | tr '{},' '\n' | grep '"sha":' | cut -d '"' -f 4
     6604}
     6605
     6606_getUpgradeHash() {
    63326607  _b="$BRANCH"
    63336608  if [ -z "$_b" ]; then
    63346609    _b="master"
    63356610  fi
    6336   _hash_url="https://api.github.com/repos/acmesh-official/$PROJECT_NAME/git/refs/heads/$_b"
    6337   _get $_hash_url | tr -d "\r\n" | tr '{},' '\n' | grep '"sha":' | cut -d '"' -f 4
     6611  _hash=$(_getRepoHash "heads/$_b")
     6612  if [ -z "$_hash" ]; then _hash=$(_getRepoHash "tags/$_b"); fi
     6613  echo $_hash
    63386614}
    63396615
     
    63416617  if (
    63426618    _initpath
    6343     [ -z "$FORCE" ] && [ "$(_getMasterHash)" = "$(_readaccountconf "UPGRADE_HASH")" ] && _info "Already uptodate!" && exit 0
     6619    [ -z "$FORCE" ] && [ "$(_getUpgradeHash)" = "$(_readaccountconf "UPGRADE_HASH")" ] && _info "Already uptodate!" && exit 0
    63446620    export LE_WORKING_DIR
    63456621    cd "$LE_WORKING_DIR"
     
    63616637  fi
    63626638
    6363   if [ "$_accountemail" ]; then
    6364     _saveaccountconf "ACCOUNT_EMAIL" "$_accountemail"
    6365   elif [ "$ACCOUNT_EMAIL" ] && [ "$ACCOUNT_EMAIL" != "$DEFAULT_ACCOUNT_EMAIL" ]; then
    6366     _saveaccountconf "ACCOUNT_EMAIL" "$ACCOUNT_EMAIL"
    6367   fi
    6368 
    63696639  if [ "$_openssl_bin" ]; then
    63706640    _saveaccountconf "ACME_OPENSSL_BIN" "$_openssl_bin"
     
    63936663      return 0
    63946664    fi
    6395     if [ "$SUDO_COMMAND" = "/bin/su" ] || [ "$SUDO_COMMAND" = "/bin/bash" ]; then
    6396       #it's a normal user doing "sudo su", or `sudo -i` or `sudo -s`
    6397       #fine
    6398       return 0
     6665    if [ -n "$SUDO_COMMAND" ]; then
     6666      #it's a normal user doing "sudo su", or `sudo -i` or `sudo -s`, or `sudo su acmeuser1`
     6667      _endswith "$SUDO_COMMAND" /bin/su || _contains "$SUDO_COMMAND" "/bin/su " || grep "^$SUDO_COMMAND\$" /etc/shells >/dev/null 2>&1
     6668      return $?
    63996669    fi
    64006670    #otherwise
     
    64026672  fi
    64036673  return 0
     6674}
     6675
     6676#server
     6677_selectServer() {
     6678  _server="$1"
     6679  _server_lower="$(echo "$_server" | _lower_case)"
     6680  _sindex=0
     6681  for snames in $CA_NAMES; do
     6682    snames="$(echo "$snames" | _lower_case)"
     6683    _sindex="$(_math $_sindex + 1)"
     6684    _debug2 "_selectServer try snames" "$snames"
     6685    for sname in $(echo "$snames" | tr ',' ' '); do
     6686      if [ "$_server_lower" = "$sname" ]; then
     6687        _debug2 "_selectServer match $sname"
     6688        _serverdir="$(_getfield "$CA_SERVERS" $_sindex)"
     6689        _debug "Selected server: $_serverdir"
     6690        ACME_DIRECTORY="$_serverdir"
     6691        export ACME_DIRECTORY
     6692        return
     6693      fi
     6694    done
     6695  done
     6696  ACME_DIRECTORY="$_server"
     6697  export ACME_DIRECTORY
     6698}
     6699
     6700#url
     6701_getCAShortName() {
     6702  caurl="$1"
     6703  if [ -z "$caurl" ]; then
     6704    caurl="$DEFAULT_CA"
     6705  fi
     6706  caurl_lower="$(echo $caurl | _lower_case)"
     6707  _sindex=0
     6708  for surl in $(echo "$CA_SERVERS" | _lower_case | tr , ' '); do
     6709    _sindex="$(_math $_sindex + 1)"
     6710    if [ "$caurl_lower" = "$surl" ]; then
     6711      _nindex=0
     6712      for snames in $CA_NAMES; do
     6713        _nindex="$(_math $_nindex + 1)"
     6714        if [ $_nindex -ge $_sindex ]; then
     6715          _getfield "$snames" 1
     6716          return
     6717        fi
     6718      done
     6719    fi
     6720  done
     6721  echo "$caurl"
     6722}
     6723
     6724#set default ca to $ACME_DIRECTORY
     6725setdefaultca() {
     6726  if [ -z "$ACME_DIRECTORY" ]; then
     6727    _err "Please give a --server parameter."
     6728    return 1
     6729  fi
     6730  _saveaccountconf "DEFAULT_ACME_SERVER" "$ACME_DIRECTORY"
     6731  _info "Changed default CA to: $(__green "$ACME_DIRECTORY")"
    64046732}
    64056733
     
    64546782  _notify_level=""
    64556783  _notify_mode=""
     6784  _revoke_reason=""
     6785  _eab_kid=""
     6786  _eab_hmac_key=""
     6787  _preferred_chain=""
    64566788  while [ ${#} -gt 0 ]; do
    64576789    case "${1}" in
    64586790
    6459       --help | -h)
    6460         showhelp
    6461         return
    6462         ;;
    6463       --version | -v)
    6464         version
    6465         return
    6466         ;;
    6467       --install)
    6468         _CMD="install"
    6469         ;;
    6470       --uninstall)
    6471         _CMD="uninstall"
    6472         ;;
    6473       --upgrade)
    6474         _CMD="upgrade"
    6475         ;;
    6476       --issue)
    6477         _CMD="issue"
    6478         ;;
    6479       --deploy)
    6480         _CMD="deploy"
    6481         ;;
    6482       --signcsr)
    6483         _CMD="signcsr"
    6484         ;;
    6485       --showcsr)
    6486         _CMD="showcsr"
    6487         ;;
    6488       --installcert | -i | --install-cert)
    6489         _CMD="installcert"
    6490         ;;
    6491       --renew | -r)
    6492         _CMD="renew"
    6493         ;;
    6494       --renewAll | --renewall | --renew-all)
    6495         _CMD="renewAll"
    6496         ;;
    6497       --revoke)
    6498         _CMD="revoke"
    6499         ;;
    6500       --remove)
    6501         _CMD="remove"
    6502         ;;
    6503       --list)
    6504         _CMD="list"
    6505         ;;
    6506       --installcronjob | --install-cronjob)
    6507         _CMD="installcronjob"
    6508         ;;
    6509       --uninstallcronjob | --uninstall-cronjob)
    6510         _CMD="uninstallcronjob"
    6511         ;;
    6512       --cron)
    6513         _CMD="cron"
    6514         ;;
    6515       --toPkcs)
    6516         _CMD="toPkcs"
    6517         ;;
    6518       --toPkcs8)
    6519         _CMD="toPkcs8"
    6520         ;;
    6521       --createAccountKey | --createaccountkey | -cak | --create-account-key)
    6522         _CMD="createAccountKey"
    6523         ;;
    6524       --createDomainKey | --createdomainkey | -cdk | --create-domain-key)
    6525         _CMD="createDomainKey"
    6526         ;;
    6527       --createCSR | --createcsr | -ccr)
    6528         _CMD="createCSR"
    6529         ;;
    6530       --deactivate)
    6531         _CMD="deactivate"
    6532         ;;
    6533       --updateaccount | --update-account)
    6534         _CMD="updateaccount"
    6535         ;;
    6536       --registeraccount | --register-account)
    6537         _CMD="registeraccount"
    6538         ;;
    6539       --deactivate-account)
    6540         _CMD="deactivateaccount"
    6541         ;;
    6542       --set-notify)
    6543         _CMD="setnotify"
    6544         ;;
    6545       --domain | -d)
    6546         _dvalue="$2"
    6547 
    6548         if [ "$_dvalue" ]; then
    6549           if _startswith "$_dvalue" "-"; then
    6550             _err "'$_dvalue' is not a valid domain for parameter '$1'"
    6551             return 1
    6552           fi
    6553           if _is_idn "$_dvalue" && ! _exists idn; then
    6554             _err "It seems that $_dvalue is an IDN( Internationalized Domain Names), please install 'idn' command first."
    6555             return 1
    6556           fi
    6557 
    6558           if _startswith "$_dvalue" "*."; then
    6559             _debug "Wildcard domain"
    6560             export ACME_VERSION=2
    6561           fi
    6562           if [ -z "$_domain" ]; then
    6563             _domain="$_dvalue"
     6791    --help | -h)
     6792      showhelp
     6793      return
     6794      ;;
     6795    --version | -v)
     6796      version
     6797      return
     6798      ;;
     6799    --install)
     6800      _CMD="install"
     6801      ;;
     6802    --uninstall)
     6803      _CMD="uninstall"
     6804      ;;
     6805    --upgrade)
     6806      _CMD="upgrade"
     6807      ;;
     6808    --issue)
     6809      _CMD="issue"
     6810      ;;
     6811    --deploy)
     6812      _CMD="deploy"
     6813      ;;
     6814    --sign-csr | --signcsr)
     6815      _CMD="signcsr"
     6816      ;;
     6817    --show-csr | --showcsr)
     6818      _CMD="showcsr"
     6819      ;;
     6820    -i | --install-cert | --installcert)
     6821      _CMD="installcert"
     6822      ;;
     6823    --renew | -r)
     6824      _CMD="renew"
     6825      ;;
     6826    --renew-all | --renewAll | --renewall)
     6827      _CMD="renewAll"
     6828      ;;
     6829    --revoke)
     6830      _CMD="revoke"
     6831      ;;
     6832    --remove)
     6833      _CMD="remove"
     6834      ;;
     6835    --list)
     6836      _CMD="list"
     6837      ;;
     6838    --install-cronjob | --installcronjob)
     6839      _CMD="installcronjob"
     6840      ;;
     6841    --uninstall-cronjob | --uninstallcronjob)
     6842      _CMD="uninstallcronjob"
     6843      ;;
     6844    --cron)
     6845      _CMD="cron"
     6846      ;;
     6847    --to-pkcs12 | --to-pkcs | --toPkcs)
     6848      _CMD="toPkcs"
     6849      ;;
     6850    --to-pkcs8 | --toPkcs8)
     6851      _CMD="toPkcs8"
     6852      ;;
     6853    --create-account-key | --createAccountKey | --createaccountkey | -cak)
     6854      _CMD="createAccountKey"
     6855      ;;
     6856    --create-domain-key | --createDomainKey | --createdomainkey | -cdk)
     6857      _CMD="createDomainKey"
     6858      ;;
     6859    -ccr | --create-csr | --createCSR | --createcsr)
     6860      _CMD="createCSR"
     6861      ;;
     6862    --deactivate)
     6863      _CMD="deactivate"
     6864      ;;
     6865    --update-account | --updateaccount)
     6866      _CMD="updateaccount"
     6867      ;;
     6868    --register-account | --registeraccount)
     6869      _CMD="registeraccount"
     6870      ;;
     6871    --deactivate-account)
     6872      _CMD="deactivateaccount"
     6873      ;;
     6874    --set-notify)
     6875      _CMD="setnotify"
     6876      ;;
     6877    --set-default-ca)
     6878      _CMD="setdefaultca"
     6879      ;;
     6880    -d | --domain)
     6881      _dvalue="$2"
     6882
     6883      if [ "$_dvalue" ]; then
     6884        if _startswith "$_dvalue" "-"; then
     6885          _err "'$_dvalue' is not a valid domain for parameter '$1'"
     6886          return 1
     6887        fi
     6888        if _is_idn "$_dvalue" && ! _exists idn; then
     6889          _err "It seems that $_dvalue is an IDN( Internationalized Domain Names), please install 'idn' command first."
     6890          return 1
     6891        fi
     6892
     6893        if _startswith "$_dvalue" "*."; then
     6894          _debug "Wildcard domain"
     6895          export ACME_VERSION=2
     6896        fi
     6897        if [ -z "$_domain" ]; then
     6898          _domain="$_dvalue"
     6899        else
     6900          if [ "$_altdomains" = "$NO_VALUE" ]; then
     6901            _altdomains="$_dvalue"
    65646902          else
    6565             if [ "$_altdomains" = "$NO_VALUE" ]; then
    6566               _altdomains="$_dvalue"
    6567             else
    6568               _altdomains="$_altdomains,$_dvalue"
    6569             fi
     6903            _altdomains="$_altdomains,$_dvalue"
    65706904          fi
    65716905        fi
    6572 
     6906      fi
     6907
     6908      shift
     6909      ;;
     6910
     6911    -f | --force)
     6912      FORCE="1"
     6913      ;;
     6914    --staging | --test)
     6915      STAGE="1"
     6916      ;;
     6917    --server)
     6918      _server="$2"
     6919      _selectServer "$_server"
     6920      shift
     6921      ;;
     6922    --debug)
     6923      if [ -z "$2" ] || _startswith "$2" "-"; then
     6924        DEBUG="$DEBUG_LEVEL_DEFAULT"
     6925      else
     6926        DEBUG="$2"
    65736927        shift
    6574         ;;
    6575 
    6576       --force | -f)
    6577         FORCE="1"
    6578         ;;
    6579       --staging | --test)
    6580         STAGE="1"
    6581         ;;
    6582       --server)
    6583         ACME_DIRECTORY="$2"
    6584         _server="$ACME_DIRECTORY"
    6585         export ACME_DIRECTORY
     6928      fi
     6929      ;;
     6930    --output-insecure)
     6931      export OUTPUT_INSECURE=1
     6932      ;;
     6933    -w | --webroot)
     6934      wvalue="$2"
     6935      if [ -z "$_webroot" ]; then
     6936        _webroot="$wvalue"
     6937      else
     6938        _webroot="$_webroot,$wvalue"
     6939      fi
     6940      shift
     6941      ;;
     6942    --challenge-alias)
     6943      cvalue="$2"
     6944      _challenge_alias="$_challenge_alias$cvalue,"
     6945      shift
     6946      ;;
     6947    --domain-alias)
     6948      cvalue="$DNS_ALIAS_PREFIX$2"
     6949      _challenge_alias="$_challenge_alias$cvalue,"
     6950      shift
     6951      ;;
     6952    --standalone)
     6953      wvalue="$NO_VALUE"
     6954      if [ -z "$_webroot" ]; then
     6955        _webroot="$wvalue"
     6956      else
     6957        _webroot="$_webroot,$wvalue"
     6958      fi
     6959      ;;
     6960    --alpn)
     6961      wvalue="$W_ALPN"
     6962      if [ -z "$_webroot" ]; then
     6963        _webroot="$wvalue"
     6964      else
     6965        _webroot="$_webroot,$wvalue"
     6966      fi
     6967      ;;
     6968    --stateless)
     6969      wvalue="$MODE_STATELESS"
     6970      if [ -z "$_webroot" ]; then
     6971        _webroot="$wvalue"
     6972      else
     6973        _webroot="$_webroot,$wvalue"
     6974      fi
     6975      ;;
     6976    --local-address)
     6977      lvalue="$2"
     6978      _local_address="$_local_address$lvalue,"
     6979      shift
     6980      ;;
     6981    --apache)
     6982      wvalue="apache"
     6983      if [ -z "$_webroot" ]; then
     6984        _webroot="$wvalue"
     6985      else
     6986        _webroot="$_webroot,$wvalue"
     6987      fi
     6988      ;;
     6989    --nginx)
     6990      wvalue="$NGINX"
     6991      if [ "$2" ] && ! _startswith "$2" "-"; then
     6992        wvalue="$NGINX$2"
    65866993        shift
    6587         ;;
    6588       --debug)
    6589         if [ -z "$2" ] || _startswith "$2" "-"; then
    6590           DEBUG="$DEBUG_LEVEL_DEFAULT"
    6591         else
    6592           DEBUG="$2"
    6593           shift
    6594         fi
    6595         ;;
    6596       --output-insecure)
    6597         export OUTPUT_INSECURE=1
    6598         ;;
    6599       --webroot | -w)
     6994      fi
     6995      if [ -z "$_webroot" ]; then
     6996        _webroot="$wvalue"
     6997      else
     6998        _webroot="$_webroot,$wvalue"
     6999      fi
     7000      ;;
     7001    --dns)
     7002      wvalue="$W_DNS"
     7003      if [ "$2" ] && ! _startswith "$2" "-"; then
    66007004        wvalue="$2"
    6601         if [ -z "$_webroot" ]; then
    6602           _webroot="$wvalue"
    6603         else
    6604           _webroot="$_webroot,$wvalue"
    6605         fi
    66067005        shift
    6607         ;;
    6608       --challenge-alias)
    6609         cvalue="$2"
    6610         _challenge_alias="$_challenge_alias$cvalue,"
     7006      fi
     7007      if [ -z "$_webroot" ]; then
     7008        _webroot="$wvalue"
     7009      else
     7010        _webroot="$_webroot,$wvalue"
     7011      fi
     7012      ;;
     7013    --dnssleep)
     7014      _dnssleep="$2"
     7015      Le_DNSSleep="$_dnssleep"
     7016      shift
     7017      ;;
     7018
     7019    --keylength | -k)
     7020      _keylength="$2"
     7021      shift
     7022      ;;
     7023    -ak | --accountkeylength)
     7024      _accountkeylength="$2"
     7025      shift
     7026      ;;
     7027
     7028    --cert-file | --certpath)
     7029      _cert_file="$2"
     7030      shift
     7031      ;;
     7032    --key-file | --keypath)
     7033      _key_file="$2"
     7034      shift
     7035      ;;
     7036    --ca-file | --capath)
     7037      _ca_file="$2"
     7038      shift
     7039      ;;
     7040    --fullchain-file | --fullchainpath)
     7041      _fullchain_file="$2"
     7042      shift
     7043      ;;
     7044    --reloadcmd | --reloadCmd)
     7045      _reloadcmd="$2"
     7046      shift
     7047      ;;
     7048    --password)
     7049      _password="$2"
     7050      shift
     7051      ;;
     7052    --accountconf)
     7053      _accountconf="$2"
     7054      ACCOUNT_CONF_PATH="$_accountconf"
     7055      shift
     7056      ;;
     7057    --home)
     7058      LE_WORKING_DIR="$2"
     7059      shift
     7060      ;;
     7061    --cert-home | --certhome)
     7062      _certhome="$2"
     7063      CERT_HOME="$_certhome"
     7064      shift
     7065      ;;
     7066    --config-home)
     7067      _confighome="$2"
     7068      LE_CONFIG_HOME="$_confighome"
     7069      shift
     7070      ;;
     7071    --useragent)
     7072      _useragent="$2"
     7073      USER_AGENT="$_useragent"
     7074      shift
     7075      ;;
     7076    -m | --accountemail)
     7077      _accountemail="$2"
     7078      ACCOUNT_EMAIL="$_accountemail"
     7079      shift
     7080      ;;
     7081    --accountkey)
     7082      _accountkey="$2"
     7083      ACCOUNT_KEY_PATH="$_accountkey"
     7084      shift
     7085      ;;
     7086    --days)
     7087      _days="$2"
     7088      Le_RenewalDays="$_days"
     7089      shift
     7090      ;;
     7091    --httpport)
     7092      _httpport="$2"
     7093      Le_HTTPPort="$_httpport"
     7094      shift
     7095      ;;
     7096    --tlsport)
     7097      _tlsport="$2"
     7098      Le_TLSPort="$_tlsport"
     7099      shift
     7100      ;;
     7101    --listraw)
     7102      _listraw="raw"
     7103      ;;
     7104    -se | --stop-renew-on-error | --stopRenewOnError | --stoprenewonerror)
     7105      _stopRenewOnError="1"
     7106      ;;
     7107    --insecure)
     7108      #_insecure="1"
     7109      HTTPS_INSECURE="1"
     7110      ;;
     7111    --ca-bundle)
     7112      _ca_bundle="$(_readlink "$2")"
     7113      CA_BUNDLE="$_ca_bundle"
     7114      shift
     7115      ;;
     7116    --ca-path)
     7117      _ca_path="$2"
     7118      CA_PATH="$_ca_path"
     7119      shift
     7120      ;;
     7121    --nocron)
     7122      _nocron="1"
     7123      ;;
     7124    --noprofile)
     7125      _noprofile="1"
     7126      ;;
     7127    --no-color)
     7128      export ACME_NO_COLOR=1
     7129      ;;
     7130    --force-color)
     7131      export ACME_FORCE_COLOR=1
     7132      ;;
     7133    --ecc)
     7134      _ecc="isEcc"
     7135      ;;
     7136    --csr)
     7137      _csr="$2"
     7138      shift
     7139      ;;
     7140    --pre-hook)
     7141      _pre_hook="$2"
     7142      shift
     7143      ;;
     7144    --post-hook)
     7145      _post_hook="$2"
     7146      shift
     7147      ;;
     7148    --renew-hook)
     7149      _renew_hook="$2"
     7150      shift
     7151      ;;
     7152    --deploy-hook)
     7153      if [ -z "$2" ] || _startswith "$2" "-"; then
     7154        _usage "Please specify a value for '--deploy-hook'"
     7155        return 1
     7156      fi
     7157      _deploy_hook="$_deploy_hook$2,"
     7158      shift
     7159      ;;
     7160    --ocsp-must-staple | --ocsp)
     7161      Le_OCSP_Staple="1"
     7162      ;;
     7163    --always-force-new-domain-key)
     7164      if [ -z "$2" ] || _startswith "$2" "-"; then
     7165        Le_ForceNewDomainKey=1
     7166      else
     7167        Le_ForceNewDomainKey="$2"
    66117168        shift
    6612         ;;
    6613       --domain-alias)
    6614         cvalue="$DNS_ALIAS_PREFIX$2"
    6615         _challenge_alias="$_challenge_alias$cvalue,"
     7169      fi
     7170      ;;
     7171    --yes-I-know-dns-manual-mode-enough-go-ahead-please)
     7172      export FORCE_DNS_MANUAL=1
     7173      ;;
     7174    --log | --logfile)
     7175      _log="1"
     7176      _logfile="$2"
     7177      if _startswith "$_logfile" '-'; then
     7178        _logfile=""
     7179      else
    66167180        shift
    6617         ;;
    6618       --standalone)
    6619         wvalue="$NO_VALUE"
    6620         if [ -z "$_webroot" ]; then
    6621           _webroot="$wvalue"
    6622         else
    6623           _webroot="$_webroot,$wvalue"
    6624         fi
    6625         ;;
    6626       --alpn)
    6627         wvalue="$W_ALPN"
    6628         if [ -z "$_webroot" ]; then
    6629           _webroot="$wvalue"
    6630         else
    6631           _webroot="$_webroot,$wvalue"
    6632         fi
    6633         ;;
    6634       --stateless)
    6635         wvalue="$MODE_STATELESS"
    6636         if [ -z "$_webroot" ]; then
    6637           _webroot="$wvalue"
    6638         else
    6639           _webroot="$_webroot,$wvalue"
    6640         fi
    6641         ;;
    6642       --local-address)
    6643         lvalue="$2"
    6644         _local_address="$_local_address$lvalue,"
     7181      fi
     7182      LOG_FILE="$_logfile"
     7183      if [ -z "$LOG_LEVEL" ]; then
     7184        LOG_LEVEL="$DEFAULT_LOG_LEVEL"
     7185      fi
     7186      ;;
     7187    --log-level)
     7188      _log_level="$2"
     7189      LOG_LEVEL="$_log_level"
     7190      shift
     7191      ;;
     7192    --syslog)
     7193      if ! _startswith "$2" '-'; then
     7194        _syslog="$2"
    66457195        shift
    6646         ;;
    6647       --apache)
    6648         wvalue="apache"
    6649         if [ -z "$_webroot" ]; then
    6650           _webroot="$wvalue"
    6651         else
    6652           _webroot="$_webroot,$wvalue"
    6653         fi
    6654         ;;
    6655       --nginx)
    6656         wvalue="$NGINX"
    6657         if [ "$2" ] && ! _startswith "$2" "-"; then
    6658           wvalue="$NGINX$2"
    6659           shift
    6660         fi
    6661         if [ -z "$_webroot" ]; then
    6662           _webroot="$wvalue"
    6663         else
    6664           _webroot="$_webroot,$wvalue"
    6665         fi
    6666         ;;
    6667       --dns)
    6668         wvalue="$W_DNS"
    6669         if [ "$2" ] && ! _startswith "$2" "-"; then
    6670           wvalue="$2"
    6671           shift
    6672         fi
    6673         if [ -z "$_webroot" ]; then
    6674           _webroot="$wvalue"
    6675         else
    6676           _webroot="$_webroot,$wvalue"
    6677         fi
    6678         ;;
    6679       --dnssleep)
    6680         _dnssleep="$2"
    6681         Le_DNSSleep="$_dnssleep"
     7196      fi
     7197      if [ -z "$_syslog" ]; then
     7198        _syslog="$SYSLOG_LEVEL_DEFAULT"
     7199      fi
     7200      ;;
     7201    --auto-upgrade)
     7202      _auto_upgrade="$2"
     7203      if [ -z "$_auto_upgrade" ] || _startswith "$_auto_upgrade" '-'; then
     7204        _auto_upgrade="1"
     7205      else
    66827206        shift
    6683         ;;
    6684 
    6685       --keylength | -k)
    6686         _keylength="$2"
    6687         shift
    6688         ;;
    6689       --accountkeylength | -ak)
    6690         _accountkeylength="$2"
    6691         shift
    6692         ;;
    6693 
    6694       --cert-file | --certpath)
    6695         _cert_file="$2"
    6696         shift
    6697         ;;
    6698       --key-file | --keypath)
    6699         _key_file="$2"
    6700         shift
    6701         ;;
    6702       --ca-file | --capath)
    6703         _ca_file="$2"
    6704         shift
    6705         ;;
    6706       --fullchain-file | --fullchainpath)
    6707         _fullchain_file="$2"
    6708         shift
    6709         ;;
    6710       --reloadcmd | --reloadCmd)
    6711         _reloadcmd="$2"
    6712         shift
    6713         ;;
    6714       --password)
    6715         _password="$2"
    6716         shift
    6717         ;;
    6718       --accountconf)
    6719         _accountconf="$2"
    6720         ACCOUNT_CONF_PATH="$_accountconf"
    6721         shift
    6722         ;;
    6723       --home)
    6724         LE_WORKING_DIR="$2"
    6725         shift
    6726         ;;
    6727       --certhome | --cert-home)
    6728         _certhome="$2"
    6729         CERT_HOME="$_certhome"
    6730         shift
    6731         ;;
    6732       --config-home)
    6733         _confighome="$2"
    6734         LE_CONFIG_HOME="$_confighome"
    6735         shift
    6736         ;;
    6737       --useragent)
    6738         _useragent="$2"
    6739         USER_AGENT="$_useragent"
    6740         shift
    6741         ;;
    6742       --accountemail)
    6743         _accountemail="$2"
    6744         ACCOUNT_EMAIL="$_accountemail"
    6745         shift
    6746         ;;
    6747       --accountkey)
    6748         _accountkey="$2"
    6749         ACCOUNT_KEY_PATH="$_accountkey"
    6750         shift
    6751         ;;
    6752       --days)
    6753         _days="$2"
    6754         Le_RenewalDays="$_days"
    6755         shift
    6756         ;;
    6757       --httpport)
    6758         _httpport="$2"
    6759         Le_HTTPPort="$_httpport"
    6760         shift
    6761         ;;
    6762       --tlsport)
    6763         _tlsport="$2"
    6764         Le_TLSPort="$_tlsport"
    6765         shift
    6766         ;;
    6767       --listraw)
    6768         _listraw="raw"
    6769         ;;
    6770       --stopRenewOnError | --stoprenewonerror | -se)
    6771         _stopRenewOnError="1"
    6772         ;;
    6773       --insecure)
    6774         #_insecure="1"
    6775         HTTPS_INSECURE="1"
    6776         ;;
    6777       --ca-bundle)
    6778         _ca_bundle="$(_readlink "$2")"
    6779         CA_BUNDLE="$_ca_bundle"
    6780         shift
    6781         ;;
    6782       --ca-path)
    6783         _ca_path="$2"
    6784         CA_PATH="$_ca_path"
    6785         shift
    6786         ;;
    6787       --nocron)
    6788         _nocron="1"
    6789         ;;
    6790       --noprofile)
    6791         _noprofile="1"
    6792         ;;
    6793       --no-color)
    6794         export ACME_NO_COLOR=1
    6795         ;;
    6796       --force-color)
    6797         export ACME_FORCE_COLOR=1
    6798         ;;
    6799       --ecc)
    6800         _ecc="isEcc"
    6801         ;;
    6802       --csr)
    6803         _csr="$2"
    6804         shift
    6805         ;;
    6806       --pre-hook)
    6807         _pre_hook="$2"
    6808         shift
    6809         ;;
    6810       --post-hook)
    6811         _post_hook="$2"
    6812         shift
    6813         ;;
    6814       --renew-hook)
    6815         _renew_hook="$2"
    6816         shift
    6817         ;;
    6818       --deploy-hook)
    6819         if [ -z "$2" ] || _startswith "$2" "-"; then
    6820           _usage "Please specify a value for '--deploy-hook'"
    6821           return 1
    6822         fi
    6823         _deploy_hook="$_deploy_hook$2,"
    6824         shift
    6825         ;;
    6826       --ocsp-must-staple | --ocsp)
    6827         Le_OCSP_Staple="1"
    6828         ;;
    6829       --always-force-new-domain-key)
    6830         if [ -z "$2" ] || _startswith "$2" "-"; then
    6831           Le_ForceNewDomainKey=1
    6832         else
    6833           Le_ForceNewDomainKey="$2"
    6834           shift
    6835         fi
    6836         ;;
    6837       --yes-I-know-dns-manual-mode-enough-go-ahead-please)
    6838         export FORCE_DNS_MANUAL=1
    6839         ;;
    6840       --log | --logfile)
    6841         _log="1"
    6842         _logfile="$2"
    6843         if _startswith "$_logfile" '-'; then
    6844           _logfile=""
    6845         else
    6846           shift
    6847         fi
    6848         LOG_FILE="$_logfile"
    6849         if [ -z "$LOG_LEVEL" ]; then
    6850           LOG_LEVEL="$DEFAULT_LOG_LEVEL"
    6851         fi
    6852         ;;
    6853       --log-level)
    6854         _log_level="$2"
    6855         LOG_LEVEL="$_log_level"
    6856         shift
    6857         ;;
    6858       --syslog)
    6859         if ! _startswith "$2" '-'; then
    6860           _syslog="$2"
    6861           shift
    6862         fi
    6863         if [ -z "$_syslog" ]; then
    6864           _syslog="$SYSLOG_LEVEL_DEFAULT"
    6865         fi
    6866         ;;
    6867       --auto-upgrade)
    6868         _auto_upgrade="$2"
    6869         if [ -z "$_auto_upgrade" ] || _startswith "$_auto_upgrade" '-'; then
    6870           _auto_upgrade="1"
    6871         else
    6872           shift
    6873         fi
    6874         AUTO_UPGRADE="$_auto_upgrade"
    6875         ;;
    6876       --listen-v4)
    6877         _listen_v4="1"
    6878         Le_Listen_V4="$_listen_v4"
    6879         ;;
    6880       --listen-v6)
    6881         _listen_v6="1"
    6882         Le_Listen_V6="$_listen_v6"
    6883         ;;
    6884       --openssl-bin)
    6885         _openssl_bin="$2"
    6886         ACME_OPENSSL_BIN="$_openssl_bin"
    6887         shift
    6888         ;;
    6889       --use-wget)
    6890         _use_wget="1"
    6891         ACME_USE_WGET="1"
    6892         ;;
    6893       --branch | -b)
    6894         export BRANCH="$2"
    6895         shift
    6896         ;;
    6897       --notify-hook)
    6898         _nhook="$2"
    6899         if _startswith "$_nhook" "-"; then
    6900           _err "'$_nhook' is not a hook name for '$1'"
    6901           return 1
    6902         fi
    6903         if [ "$_notify_hook" ]; then
    6904           _notify_hook="$_notify_hook,$_nhook"
    6905         else
    6906           _notify_hook="$_nhook"
    6907         fi
    6908         shift
    6909         ;;
    6910       --notify-level)
    6911         _nlevel="$2"
    6912         if _startswith "$_nlevel" "-"; then
    6913           _err "'$_nlevel' is not a integer for '$1'"
    6914           return 1
    6915         fi
    6916         _notify_level="$_nlevel"
    6917         shift
    6918         ;;
    6919       --notify-mode)
    6920         _nmode="$2"
    6921         if _startswith "$_nmode" "-"; then
    6922           _err "'$_nmode' is not a integer for '$1'"
    6923           return 1
    6924         fi
    6925         _notify_mode="$_nmode"
    6926         shift
    6927         ;;
    6928       *)
    6929         _err "Unknown parameter : $1"
     7207      fi
     7208      AUTO_UPGRADE="$_auto_upgrade"
     7209      ;;
     7210    --listen-v4)
     7211      _listen_v4="1"
     7212      Le_Listen_V4="$_listen_v4"
     7213      ;;
     7214    --listen-v6)
     7215      _listen_v6="1"
     7216      Le_Listen_V6="$_listen_v6"
     7217      ;;
     7218    --openssl-bin)
     7219      _openssl_bin="$2"
     7220      ACME_OPENSSL_BIN="$_openssl_bin"
     7221      shift
     7222      ;;
     7223    --use-wget)
     7224      _use_wget="1"
     7225      ACME_USE_WGET="1"
     7226      ;;
     7227    --branch | -b)
     7228      export BRANCH="$2"
     7229      shift
     7230      ;;
     7231    --notify-hook)
     7232      _nhook="$2"
     7233      if _startswith "$_nhook" "-"; then
     7234        _err "'$_nhook' is not a hook name for '$1'"
    69307235        return 1
    6931         ;;
     7236      fi
     7237      if [ "$_notify_hook" ]; then
     7238        _notify_hook="$_notify_hook,$_nhook"
     7239      else
     7240        _notify_hook="$_nhook"
     7241      fi
     7242      shift
     7243      ;;
     7244    --notify-level)
     7245      _nlevel="$2"
     7246      if _startswith "$_nlevel" "-"; then
     7247        _err "'$_nlevel' is not a integer for '$1'"
     7248        return 1
     7249      fi
     7250      _notify_level="$_nlevel"
     7251      shift
     7252      ;;
     7253    --notify-mode)
     7254      _nmode="$2"
     7255      if _startswith "$_nmode" "-"; then
     7256        _err "'$_nmode' is not a integer for '$1'"
     7257        return 1
     7258      fi
     7259      _notify_mode="$_nmode"
     7260      shift
     7261      ;;
     7262    --revoke-reason)
     7263      _revoke_reason="$2"
     7264      if _startswith "$_revoke_reason" "-"; then
     7265        _err "'$_revoke_reason' is not a integer for '$1'"
     7266        return 1
     7267      fi
     7268      shift
     7269      ;;
     7270    --eab-kid)
     7271      _eab_kid="$2"
     7272      shift
     7273      ;;
     7274    --eab-hmac-key)
     7275      _eab_hmac_key="$2"
     7276      shift
     7277      ;;
     7278    --preferred-chain)
     7279      _preferred_chain="$2"
     7280      shift
     7281      ;;
     7282    *)
     7283      _err "Unknown parameter : $1"
     7284      return 1
     7285      ;;
    69327286    esac
    69337287
     
    69887342  _debug "Running cmd: ${_CMD}"
    69897343  case "${_CMD}" in
    6990     install) install "$_nocron" "$_confighome" "$_noprofile" ;;
    6991     uninstall) uninstall "$_nocron" ;;
    6992     upgrade) upgrade ;;
    6993     issue)
    6994       issue "$_webroot" "$_domain" "$_altdomains" "$_keylength" "$_cert_file" "$_key_file" "$_ca_file" "$_reloadcmd" "$_fullchain_file" "$_pre_hook" "$_post_hook" "$_renew_hook" "$_local_address" "$_challenge_alias"
    6995       ;;
    6996     deploy)
    6997       deploy "$_domain" "$_deploy_hook" "$_ecc"
    6998       ;;
    6999     signcsr)
    7000       signcsr "$_csr" "$_webroot" "$_cert_file" "$_key_file" "$_ca_file" "$_reloadcmd" "$_fullchain_file" "$_pre_hook" "$_post_hook" "$_renew_hook" "$_local_address" "$_challenge_alias"
    7001       ;;
    7002     showcsr)
    7003       showcsr "$_csr" "$_domain"
    7004       ;;
    7005     installcert)
    7006       installcert "$_domain" "$_cert_file" "$_key_file" "$_ca_file" "$_reloadcmd" "$_fullchain_file" "$_ecc"
    7007       ;;
    7008     renew)
    7009       renew "$_domain" "$_ecc"
    7010       ;;
    7011     renewAll)
    7012       renewAll "$_stopRenewOnError"
    7013       ;;
    7014     revoke)
    7015       revoke "$_domain" "$_ecc"
    7016       ;;
    7017     remove)
    7018       remove "$_domain" "$_ecc"
    7019       ;;
    7020     deactivate)
    7021       deactivate "$_domain,$_altdomains"
    7022       ;;
    7023     registeraccount)
    7024       registeraccount "$_accountkeylength"
    7025       ;;
    7026     updateaccount)
    7027       updateaccount
    7028       ;;
    7029     deactivateaccount)
    7030       deactivateaccount
    7031       ;;
    7032     list)
    7033       list "$_listraw"
    7034       ;;
    7035     installcronjob) installcronjob "$_confighome" ;;
    7036     uninstallcronjob) uninstallcronjob ;;
    7037     cron) cron ;;
    7038     toPkcs)
    7039       toPkcs "$_domain" "$_password" "$_ecc"
    7040       ;;
    7041     toPkcs8)
    7042       toPkcs8 "$_domain" "$_ecc"
    7043       ;;
    7044     createAccountKey)
    7045       createAccountKey "$_accountkeylength"
    7046       ;;
    7047     createDomainKey)
    7048       createDomainKey "$_domain" "$_keylength"
    7049       ;;
    7050     createCSR)
    7051       createCSR "$_domain" "$_altdomains" "$_ecc"
    7052       ;;
    7053     setnotify)
    7054       setnotify "$_notify_hook" "$_notify_level" "$_notify_mode"
    7055       ;;
    7056     *)
    7057       if [ "$_CMD" ]; then
    7058         _err "Invalid command: $_CMD"
    7059       fi
    7060       showhelp
    7061       return 1
    7062       ;;
     7344  install) install "$_nocron" "$_confighome" "$_noprofile" ;;
     7345  uninstall) uninstall "$_nocron" ;;
     7346  upgrade) upgrade ;;
     7347  issue)
     7348    issue "$_webroot" "$_domain" "$_altdomains" "$_keylength" "$_cert_file" "$_key_file" "$_ca_file" "$_reloadcmd" "$_fullchain_file" "$_pre_hook" "$_post_hook" "$_renew_hook" "$_local_address" "$_challenge_alias" "$_preferred_chain"
     7349    ;;
     7350  deploy)
     7351    deploy "$_domain" "$_deploy_hook" "$_ecc"
     7352    ;;
     7353  signcsr)
     7354    signcsr "$_csr" "$_webroot" "$_cert_file" "$_key_file" "$_ca_file" "$_reloadcmd" "$_fullchain_file" "$_pre_hook" "$_post_hook" "$_renew_hook" "$_local_address" "$_challenge_alias"
     7355    ;;
     7356  showcsr)
     7357    showcsr "$_csr" "$_domain"
     7358    ;;
     7359  installcert)
     7360    installcert "$_domain" "$_cert_file" "$_key_file" "$_ca_file" "$_reloadcmd" "$_fullchain_file" "$_ecc"
     7361    ;;
     7362  renew)
     7363    renew "$_domain" "$_ecc"
     7364    ;;
     7365  renewAll)
     7366    renewAll "$_stopRenewOnError"
     7367    ;;
     7368  revoke)
     7369    revoke "$_domain" "$_ecc" "$_revoke_reason"
     7370    ;;
     7371  remove)
     7372    remove "$_domain" "$_ecc"
     7373    ;;
     7374  deactivate)
     7375    deactivate "$_domain,$_altdomains"
     7376    ;;
     7377  registeraccount)
     7378    registeraccount "$_accountkeylength" "$_eab_kid" "$_eab_hmac_key"
     7379    ;;
     7380  updateaccount)
     7381    updateaccount
     7382    ;;
     7383  deactivateaccount)
     7384    deactivateaccount
     7385    ;;
     7386  list)
     7387    list "$_listraw" "$_domain"
     7388    ;;
     7389  installcronjob) installcronjob "$_confighome" ;;
     7390  uninstallcronjob) uninstallcronjob ;;
     7391  cron) cron ;;
     7392  toPkcs)
     7393    toPkcs "$_domain" "$_password" "$_ecc"
     7394    ;;
     7395  toPkcs8)
     7396    toPkcs8 "$_domain" "$_ecc"
     7397    ;;
     7398  createAccountKey)
     7399    createAccountKey "$_accountkeylength"
     7400    ;;
     7401  createDomainKey)
     7402    createDomainKey "$_domain" "$_keylength"
     7403    ;;
     7404  createCSR)
     7405    createCSR "$_domain" "$_altdomains" "$_ecc"
     7406    ;;
     7407  setnotify)
     7408    setnotify "$_notify_hook" "$_notify_level" "$_notify_mode"
     7409    ;;
     7410  setdefaultca)
     7411    setdefaultca
     7412    ;;
     7413  *)
     7414    if [ "$_CMD" ]; then
     7415      _err "Invalid command: $_CMD"
     7416    fi
     7417    showhelp
     7418    return 1
     7419    ;;
    70637420  esac
    70647421  _ret="$?"
  • npl/syn3/acme/root/usr/bin/syn3-acme-issue

    r30f002a r6e9c61f  
    55
    66echo "SYN-3: Issueing TEST certificate"
    7 if syn3-acme --config-home /etc/acme/test --test --issue --standalone $DOMAINS $@; then
     7if syn3-acme --config-home /etc/acme/test --force --test --issue --standalone $DOMAINS $@; then
    88        echo "SYN-3: Issueing LIVE certificate"
    99        syn3-acme --config-home /etc/acme/live --issue --standalone --fullchain-file /usr/webint/ssl/server.crt --key-file /usr/webint/ssl/server.pem $DOMAINS $@
     
    1515
    1616if [ "$EXIT" == "0" ]; then
     17        cat /usr/webint/ssl/server.crt /usr/webint/ssl/server.key  > /usr/webint/ssl/certandkey.pem
    1718        syn3-state certbot OK "SSL certificate valid."
    1819fi
    1920
     21
    2022exit $EXIT
  • npl/syn3/acme/root/usr/bin/syn3-acme-renew

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

    r30f002a r6e9c61f  
    1 9
     110
  • npl/syn3/acme/syn3_acme.md5

    r30f002a r6e9c61f  
    11d41d8cd98f00b204e9800998ecf8427e  ./root/etc/webint/SSL_DOMAINS.new
    2 9215d7b19618c71a42df9326d86ad16f  ./root/usr/bin/acme.sh
     20418c2dac1c09a1e0a5a923de7155251  ./root/usr/bin/acme.sh
    33a0e5403f61c08e4eda04cd2e61d7938a  ./root/usr/bin/syn3-acme
    4 cb7232508745b67caad455dd54cd8bb9  ./root/usr/bin/syn3-acme-issue
    5 f5eca94149edc261a950c497533c71a2  ./root/usr/bin/syn3-acme-renew
    6 fe2fd64e8e4592834c27d7978aebcde4  ./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 556f9498697435671507e661abe96a95  ./syn3_acme.SlackBuild.log.gz
     86c17d788610977961a07f821dad6ccc3  ./syn3_acme.SlackBuild.log.gz
Note: See TracChangeset for help on using the changeset viewer.