Changeset 6e9c61f
- Timestamp:
- 12/14/20 16:40:34 (4 years ago)
- Branches:
- master
- Children:
- a051af0
- Parents:
- 30f002a
- Location:
- npl/syn3/acme
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
npl/syn3/acme/root/usr/bin/acme.sh
r30f002a r6e9c61f 1 1 #!/usr/bin/env sh 2 2 3 VER=2.8. 63 VER=2.8.8 4 4 5 5 PROJECT_NAME="acme.sh" … … 24 24 LETSENCRYPT_STAGING_CA_V1="https://acme-staging.api.letsencrypt.org/directory" 25 25 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 26 CA_LETSENCRYPT_V2="https://acme-v02.api.letsencrypt.org/directory" 27 CA_LETSENCRYPT_V2_TEST="https://acme-staging-v02.api.letsencrypt.org/directory" 28 29 CA_BUYPASS="https://api.buypass.com/acme/directory" 30 CA_BUYPASS_TEST="https://api.test4.buypass.no/acme/directory" 31 32 CA_ZEROSSL="https://acme.zerossl.com/v2/DV90" 33 _ZERO_EAB_ENDPOINT="http://api.zerossl.com/acme/eab-credentials-email" 34 35 DEFAULT_CA=$CA_LETSENCRYPT_V2 36 DEFAULT_STAGING_CA=$CA_LETSENCRYPT_V2_TEST 37 38 CA_NAMES=" 39 LetsEncrypt.org,letsencrypt 40 LetsEncrypt.org_test,letsencrypt_test,letsencrypttest 41 BuyPass.com,buypass 42 BuyPass.com_test,buypass_test,buypasstest 43 ZeroSSL.com,zerossl 44 " 45 46 CA_SERVERS="$CA_LETSENCRYPT_V2,$CA_LETSENCRYPT_V2_TEST,$CA_BUYPASS,$CA_BUYPASS_TEST,$CA_ZEROSSL" 31 47 32 48 DEFAULT_USER_AGENT="$PROJECT_NAME/$VER ($PROJECT)" 33 DEFAULT_ACCOUNT_EMAIL=""34 49 35 50 DEFAULT_ACCOUNT_KEY_LENGTH=2048 … … 37 52 38 53 DEFAULT_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"42 54 43 55 VTYPE_HTTP="http-01" … … 48 60 49 61 DEFAULT_RENEW=60 50 51 DEFAULT_DNS_SLEEP=12052 62 53 63 NO_VALUE="no" … … 137 147 _DNS_MANUAL_WIKI="https://github.com/acmesh-official/acme.sh/wiki/dns-manual-mode" 138 148 149 _DNS_API_WIKI="https://github.com/acmesh-official/acme.sh/wiki/dnsapi" 150 139 151 _NOTIFY_WIKI="https://github.com/acmesh-official/acme.sh/wiki/notify" 140 152 141 153 _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" 142 162 143 163 _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." … … 189 209 ${ACME_OPENSSL_BIN:-openssl} version 2>&1 190 210 else 191 echo "$ACME_OPENSSL_BIN doesn't exist s."211 echo "$ACME_OPENSSL_BIN doesn't exist." 192 212 fi 193 213 … … 196 216 $_APACHECTL -V 2>&1 197 217 else 198 echo "apache doesn't exist s."218 echo "apache doesn't exist." 199 219 fi 200 220 … … 203 223 nginx -V 2>&1 204 224 else 205 echo "nginx doesn't exist s."225 echo "nginx doesn't exist." 206 226 fi 207 227 … … 210 230 socat -V 2>&1 211 231 else 212 _debug "socat doesn't exist s."232 _debug "socat doesn't exist." 213 233 fi 214 234 } … … 505 525 _ch=$1 506 526 case "${_ch}" in 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 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 ;; 528 548 esac 529 549 … … 633 653 #upper case 634 654 case "${_hex_code}" in 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 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 ;; 713 733 714 734 #lower case 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 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 ;; 793 813 #numbers 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 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 ;; 840 860 esac 841 861 done … … 847 867 _debug3 "_j_str" "$_j_str" 848 868 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" 849 877 } 850 878 … … 929 957 _cf="$1" 930 958 if [ "$DEBUG" ]; then 931 opensslx509 -noout -text -in "$_cf"932 else 933 opensslx509 -noout -text -in "$_cf" >/dev/null 2>&1959 ${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 934 962 fi 935 963 } … … 996 1024 _sign_openssl="${ACME_OPENSSL_BIN:-openssl} dgst -sign $keyfile " 997 1025 998 if grep "BEGIN RSA PRIVATE KEY" "$keyfile" >/dev/null 2>&1 ; then1026 if grep "BEGIN RSA PRIVATE KEY" "$keyfile" >/dev/null 2>&1 || grep "BEGIN PRIVATE KEY" "$keyfile" >/dev/null 2>&1; then 999 1027 $_sign_openssl -$alg | _base64 1000 1028 elif grep "BEGIN EC PRIVATE KEY" "$keyfile" >/dev/null 2>&1; then … … 1007 1035 _debug3 "_signedECText" "$_signedECText" 1008 1036 _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 1009 1062 _debug3 "_ec_r" "$_ec_r" 1010 _ec_s="$(echo "$_signedECText" | _head_n 3 | _tail_n 1 | cut -d : -f 4 | tr -d "\r\n")"1011 1063 _debug3 "_ec_s" "$_ec_s" 1012 1064 printf "%s" "$_ec_r$_ec_s" | _h2b | _base64 … … 1026 1078 fi 1027 1079 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" ] 1033 1085 } 1034 1086 … … 1167 1219 printf -- "\nsubjectAltName=$alt" >>"$csrconf" 1168 1220 fi 1169 if [ "$Le_OCSP_Staple" ] || [ "$Le_OCSP_Stable" ]; then1221 if [ "$Le_OCSP_Staple" = "1" ]; then 1170 1222 _savedomainconf Le_OCSP_Staple "$Le_OCSP_Staple" 1171 _cleardomainconf Le_OCSP_Stable1172 1223 printf -- "\nbasicConstraints = CA:FALSE\n1.3.6.1.5.5.7.1.24=DER:30:03:02:01:05" >>"$csrconf" 1173 1224 fi … … 1325 1376 pfxPassword="$2" 1326 1377 if [ -z "$domain" ]; then 1327 _usage "Usage: $PROJECT_ENTRY --to Pkcs -d domain [--password pfx-password]"1378 _usage "Usage: $PROJECT_ENTRY --to-pkcs12 --domain <domain.tld> [--password <password>] [--ecc]" 1328 1379 return 1 1329 1380 fi … … 1346 1397 1347 1398 if [ -z "$domain" ]; then 1348 _usage "Usage: $PROJECT_ENTRY --to Pkcs8 -d domain[--ecc]"1399 _usage "Usage: $PROJECT_ENTRY --to-pkcs8 --domain <domain.tld> [--ecc]" 1349 1400 return 1 1350 1401 fi … … 1366 1417 _info "Creating account key" 1367 1418 if [ -z "$1" ]; then 1368 _usage "Usage: $PROJECT_ENTRY --create AccountKey --accountkeylength 2048"1419 _usage "Usage: $PROJECT_ENTRY --create-account-key [--accountkeylength <bits>]" 1369 1420 return 1370 1421 fi … … 1409 1460 _info "Creating domain key" 1410 1461 if [ -z "$1" ]; then 1411 _usage "Usage: $PROJECT_ENTRY --create DomainKey -d domain.com [ --keylength 2048]"1462 _usage "Usage: $PROJECT_ENTRY --create-domain-key --domain <domain.tld> [--keylength <bits>]" 1412 1463 return 1413 1464 fi … … 1423 1474 _initpath "$domain" "$_cdl" 1424 1475 1425 if [ ! -f "$CERT_KEY_PATH" ] || [ ! -s "$CERT_KEY_PATH" ] || ([ "$FORCE" ] && ! [ "$ IS_RENEW" ]) || [ "$Le_ForceNewDomainKey" = "1" ]; then1476 if [ ! -f "$CERT_KEY_PATH" ] || [ ! -s "$CERT_KEY_PATH" ] || ([ "$FORCE" ] && ! [ "$_ACME_IS_RENEW" ]) || [ "$Le_ForceNewDomainKey" = "1" ]; then 1426 1477 if _createkey "$_cdl" "$CERT_KEY_PATH"; then 1427 1478 _savedomainconf Le_Keylength "$_cdl" … … 1433 1484 fi 1434 1485 else 1435 if [ "$ IS_RENEW" ]; then1486 if [ "$_ACME_IS_RENEW" ]; then 1436 1487 _info "Domain key exists, skip" 1437 1488 return 0 … … 1449 1500 _info "Creating csr" 1450 1501 if [ -z "$1" ]; then 1451 _usage "Usage: $PROJECT_ENTRY --create CSR -d domain1.com [-d domain2.com -d domain3.com ...]"1502 _usage "Usage: $PROJECT_ENTRY --create-csr --domain <domain.tld> [--domain <domain2.tld> ...]" 1452 1503 return 1453 1504 fi … … 1459 1510 _initpath "$domain" "$_isEcc" 1460 1511 1461 if [ -f "$CSR_PATH" ] && [ "$ IS_RENEW" ] && [ -z "$FORCE" ]; then1512 if [ -f "$CSR_PATH" ] && [ "$_ACME_IS_RENEW" ] && [ -z "$FORCE" ]; then 1462 1513 _info "CSR exists, skip" 1463 1514 return … … 1475 1526 _url_replace() { 1476 1527 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 '_-' '/+' 1477 1541 } 1478 1542 … … 1567 1631 _debug3 crv_oid "$crv_oid" 1568 1632 case "${crv_oid}" in 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 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 ;; 1585 1649 esac 1586 1650 _debug3 crv "$crv" … … 1659 1723 } 1660 1724 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 1661 1733 _inithttp() { 1662 1734 … … 1674 1746 1675 1747 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 1677 1752 if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ]; then 1678 1753 _CURL_DUMP="$(_mktemp)" … … 1693 1768 if [ -z "$_ACME_WGET" ] && _exists "wget"; then 1694 1769 _ACME_WGET="wget -q" 1770 if [ "$ACME_HTTP_NO_REDIRECTS" ]; then 1771 _ACME_WGET="$_ACME_WGET --max-redirect 0 " 1772 fi 1695 1773 if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ]; then 1696 1774 _ACME_WGET="$_ACME_WGET -d " … … 1980 2058 fi 1981 2059 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 1983 2063 protected="$JWK_HEADERPLACE_PART1$nonce\", \"url\": \"${url}$JWK_HEADERPLACE_PART2, \"jwk\": $jwk"'}' 1984 2064 else … … 2021 2101 _debug2 original "$response" 2022 2102 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)" 2024 2104 fi 2025 2105 _debug2 response "$response" … … 2438 2518 return 1 2439 2519 fi 2520 response=$(echo "$response" | _json_decode) 2440 2521 _debug2 "response" "$response" 2441 2522 … … 2520 2601 fi 2521 2602 2522 if [ "$ ACME_IN_CRON" ]; then2603 if [ "$_ACME_IN_CRON" ]; then 2523 2604 if [ ! "$_USER_PATH_EXPORTED" ]; then 2524 2605 _USER_PATH_EXPORTED=1 … … 2531 2612 fi 2532 2613 2533 if [ "$ACME_VERSION" = "2" ]; then2534 DEFAULT_CA="$LETSENCRYPT_CA_V2"2535 DEFAULT_STAGING_CA="$LETSENCRYPT_STAGING_CA_V2"2536 fi2537 2538 2614 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" 2541 2618 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 2544 2626 fi 2545 2627 fi … … 2793 2875 apacheVer="$($_APACHECTL -V | grep "Server version:" | cut -d : -f 2 | cut -d " " -f 2 | cut -d '/' -f 2)" 2794 2876 _debug "apacheVer" "$apacheVer" 2795 apacheMaj er="$(echo "$apacheVer" | cut -d . -f 1)"2877 apacheMajor="$(echo "$apacheVer" | cut -d . -f 1)" 2796 2878 apacheMinor="$(echo "$apacheVer" | cut -d . -f 2)" 2797 2879 2798 if [ "$apacheVer" ] && [ "$apacheMaj er$apacheMinor" -ge "24" ]; then2880 if [ "$apacheVer" ] && [ "$apacheMajor$apacheMinor" -ge "24" ]; then 2799 2881 echo " 2800 2882 Alias /.well-known/acme-challenge $ACME_DIR … … 2821 2903 _err "The apache config file is restored." 2822 2904 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." 2824 2906 fi 2825 2907 return 1 … … 3321 3403 fi 3322 3404 3323 if [ "$ IS_RENEW" = "1" ] && _hasfield "$Le_Webroot" "$W_DNS"; then3405 if [ "$_ACME_IS_RENEW" = "1" ] && _hasfield "$Le_Webroot" "$W_DNS"; then 3324 3406 _err "$_DNS_MANUAL_ERR" 3325 3407 fi … … 3353 3435 3354 3436 #run renew hook 3355 if [ "$ IS_RENEW" ] && [ "$_chk_renew_hook" ]; then3437 if [ "$_ACME_IS_RENEW" ] && [ "$_chk_renew_hook" ]; then 3356 3438 _info "Run renew hook:'$_chk_renew_hook'" 3357 3439 if ! ( … … 3374 3456 } 3375 3457 3458 #account_key_length eab-kid eab-hmac-key 3376 3459 registeraccount() { 3377 _reg_length="$1" 3460 _account_key_length="$1" 3461 _eab_id="$2" 3462 _eab_hmac_key="$3" 3378 3463 _initpath 3379 _regAccount "$_ reg_length"3464 _regAccount "$_account_key_length" "$_eab_id" "$_eab_hmac_key" 3380 3465 } 3381 3466 … … 3386 3471 __calc_account_thumbprint() { 3387 3472 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" 3388 3488 } 3389 3489 … … 3392 3492 _initpath 3393 3493 _reg_length="$1" 3494 _eab_id="$2" 3495 _eab_hmac_key="$3" 3394 3496 _debug3 _regAccount "$_regAccount" 3395 3497 _initAPI … … 3416 3518 return 1 3417 3519 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 3419 3532 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}" 3424 3587 else 3425 3588 _reg_res="$ACME_NEW_ACCOUNT_RES" 3426 3589 regjson='{"resource": "'$_reg_res'", "terms-of-service-agreed": true, "agreement": "'$ACME_AGREEMENT'"}' 3427 if [ "$ ACCOUNT_EMAIL" ]; then3428 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" 3433 3596 3434 3597 if ! _send_signed_request "${ACME_NEW_ACCOUNT}" "$regjson"; then … … 3437 3600 fi 3438 3601 3602 _eabAlreadyBound="" 3439 3603 if [ "$code" = "" ] || [ "$code" = '201' ]; then 3440 3604 echo "$response" >"$ACCOUNT_JSON_PATH" … … 3442 3606 elif [ "$code" = '409' ] || [ "$code" = '200' ]; then 3443 3607 _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 3444 3611 else 3445 3612 _err "Register account Error: $response" … … 3447 3614 fi 3448 3615 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 3458 3629 export ACCOUNT_URL="$_accUri" 3459 3630 … … 3504 3675 _initAPI 3505 3676 3677 _email="$(_getAccountEmail)" 3506 3678 if [ "$ACME_VERSION" = "2" ]; then 3507 3679 if [ "$ACCOUNT_EMAIL" ]; then 3508 updjson='{"contact": ["mailto: '$ACCOUNT_EMAIL'"]}' 3680 updjson='{"contact": ["mailto:'$_email'"]}' 3681 else 3682 updjson='{"contact": []}' 3509 3683 fi 3510 3684 else … … 3519 3693 3520 3694 if [ "$code" = '200' ]; then 3695 echo "$response" >"$ACCOUNT_JSON_PATH" 3521 3696 _info "account update success for $_accUri." 3522 3697 else … … 3830 4005 } 3831 4006 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 3832 4031 #webroot, domain domainlist keylength 3833 4032 issue() { 3834 4033 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>" 3836 4035 return 1 3837 4036 fi … … 3862 4061 _local_addr="${13}" 3863 4062 _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 3876 4066 _initpath "$_main_domain" "$_key_length" 3877 4067 mkdir -p "$DOMAIN_PATH" … … 3924 4114 _cleardomainconf "Le_ChallengeAlias" 3925 4115 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" 3934 4126 if [ "$_alt_domains" = "$NO_VALUE" ]; then 3935 4127 _alt_domains="" … … 4021 4213 _savedomainconf "Le_OrderFinalize" "$Le_OrderFinalize" 4022 4214 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 '"')" 4024 4216 _debug2 _authorizations_seg "$_authorizations_seg" 4025 4217 if [ -z "$_authorizations_seg" ]; then … … 4087 4279 if [ "$ACME_VERSION" = "2" ]; then 4088 4280 _idn_d="$(_idn "$d")" 4089 _candi ndates="$(echo "$_authorizations_map" | grep -i "^$_idn_d,")"4090 _debug2 _candi ndates "$_candindates"4091 if [ "$(echo "$_candi ndates" | wc -l)" -gt 1 ]; then4092 for _can in $_candi ndates; do4281 _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 4093 4285 if _startswith "$(echo "$_can" | tr '.' '|')" "$(echo "$_idn_d" | tr '.' '|'),"; then 4094 _candi ndates="$_can"4286 _candidates="$_can" 4095 4287 break 4096 4288 fi 4097 4289 done 4098 4290 fi 4099 response="$(echo "$_candi ndates" | sed "s/$_idn_d,//")"4291 response="$(echo "$_candidates" | sed "s/$_idn_d,//")" 4100 4292 _debug2 "response" "$response" 4101 4293 if [ -z "$response" ]; then … … 4288 4480 if [ "$dns_entries" ]; then 4289 4481 if [ -z "$Le_DNSSleep" ]; then 4290 _info "Let's check each dns recordsnow. Sleep 20 seconds first."4482 _info "Let's check each DNS record now. Sleep 20 seconds first." 4291 4483 _sleep 20 4292 4484 if ! _check_dns_entries; then … … 4523 4715 4524 4716 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" 4526 4719 if ! _send_signed_request "${Le_OrderFinalize}" "{\"csr\": \"$der\"}"; then 4527 4720 _err "Sign failed." … … 4536 4729 fi 4537 4730 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-)" 4539 4732 fi 4540 4733 … … 4542 4735 4543 4736 _link_cert_retry=0 4544 _MAX_CERT_RETRY= 54737 _MAX_CERT_RETRY=30 4545 4738 while [ "$_link_cert_retry" -lt "$_MAX_CERT_RETRY" ]; do 4546 4739 if _contains "$response" "\"status\":\"valid\""; then … … 4557 4750 elif _contains "$response" "\"processing\""; then 4558 4751 _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 4560 4760 else 4561 4761 _err "Sign error, wrong status" … … 4587 4787 return 1 4588 4788 fi 4589 _info "Download cert, Le_LinkCert: $Le_LinkCert" 4789 _info "Downloading cert." 4790 _info "Le_LinkCert" "$Le_LinkCert" 4590 4791 if ! _send_signed_request "$Le_LinkCert"; then 4591 4792 _err "Sign failed, can not download cert:$Le_LinkCert." … … 4596 4797 4597 4798 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 4609 4827 else 4610 4828 if ! _send_signed_request "${ACME_NEW_ORDER}" "{\"resource\": \"$ACME_NEW_ORDER_RES\", \"csr\": \"$der\"}" "needbase64"; then … … 4650 4868 fi 4651 4869 4652 if [ ! "$USER_PATH" ] || [ ! "$ ACME_IN_CRON" ]; then4870 if [ ! "$USER_PATH" ] || [ ! "$_ACME_IN_CRON" ]; then 4653 4871 USER_PATH="$PATH" 4654 4872 _saveaccountconf "USER_PATH" "$USER_PATH" … … 4775 4993 } 4776 4994 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 4777 5011 #domain [isEcc] 4778 5012 renew() { 4779 5013 Le_Domain="$1" 4780 5014 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]" 4782 5016 return 1 4783 5017 fi … … 4789 5023 _info "$(__green "Renew: '$Le_Domain'")" 4790 5024 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." 4792 5026 return $RENEW_SKIP 4793 5027 fi … … 4810 5044 4811 5045 if [ "$Le_API" ]; then 4812 if [ "$_OLD_CA_HOST" = "$Le_API" ]; then4813 export Le_API="$DEFAULT_CA"4814 _savedomainconf Le_API "$Le_API"4815 fi4816 if [ "$_OLD_STAGE_CA_HOST" = "$Le_API" ]; then4817 export Le_API="$DEFAULT_STAGING_CA"4818 _savedomainconf Le_API "$Le_API"4819 fi4820 5046 export ACME_DIRECTORY="$Le_API" 4821 5047 #reload ca configs … … 4833 5059 fi 4834 5060 4835 if [ "$ ACME_IN_CRON" = "1" ] && [ -z "$Le_CertCreateTime" ]; then5061 if [ "$_ACME_IN_CRON" = "1" ] && [ -z "$Le_CertCreateTime" ]; then 4836 5062 _info "Skip invalid cert for: $Le_Domain" 4837 5063 return $RENEW_SKIP 4838 5064 fi 4839 5065 4840 IS_RENEW="1"5066 _ACME_IS_RENEW="1" 4841 5067 Le_ReloadCmd="$(_readdomainconf Le_ReloadCmd)" 4842 5068 Le_PreHook="$(_readdomainconf Le_PreHook)" 4843 5069 Le_PostHook="$(_readdomainconf Le_PostHook)" 4844 5070 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" 4846 5073 res="$?" 4847 5074 if [ "$res" != "0" ]; then … … 4854 5081 fi 4855 5082 4856 IS_RENEW=""5083 _ACME_IS_RENEW="" 4857 5084 4858 5085 return "$res" … … 4875 5102 _debug di "$di" 4876 5103 if ! [ -d "$di" ]; then 4877 _debug "Not directory, skip: $di"5104 _debug "Not a directory, skip: $di" 4878 5105 continue 4879 5106 fi … … 4894 5121 _notify_code=0 4895 5122 fi 4896 if [ "$ ACME_IN_CRON" ]; then5123 if [ "$_ACME_IN_CRON" ]; then 4897 5124 if [ $_set_level -ge $NOTIFY_LEVEL_RENEW ]; then 4898 5125 if [ "$NOTIFY_MODE" = "$NOTIFY_MODE_CERT" ]; then … … 4908 5135 _notify_code=$RENEW_SKIP 4909 5136 fi 4910 if [ "$ ACME_IN_CRON" ]; then5137 if [ "$_ACME_IN_CRON" ]; then 4911 5138 if [ $_set_level -ge $NOTIFY_LEVEL_SKIP ]; then 4912 5139 if [ "$NOTIFY_MODE" = "$NOTIFY_MODE_CERT" ]; then … … 4923 5150 _notify_code=1 4924 5151 fi 4925 if [ "$ ACME_IN_CRON" ]; then5152 if [ "$_ACME_IN_CRON" ]; then 4926 5153 if [ $_set_level -ge $NOTIFY_LEVEL_ERROR ]; then 4927 5154 if [ "$NOTIFY_MODE" = "$NOTIFY_MODE_CERT" ]; then … … 4944 5171 _debug _error_level "$_error_level" 4945 5172 _debug _set_level "$_set_level" 4946 if [ "$ ACME_IN_CRON" ] && [ $_error_level -le $_set_level ]; then5173 if [ "$_ACME_IN_CRON" ] && [ $_error_level -le $_set_level ]; then 4947 5174 if [ -z "$NOTIFY_MODE" ] || [ "$NOTIFY_MODE" = "$NOTIFY_MODE_BULK" ]; then 4948 5175 _msg_subject="Renew" … … 4978 5205 _csrW="$2" 4979 5206 if [ -z "$_csrfile" ] || [ -z "$_csrW" ]; then 4980 _usage "Usage: $PROJECT_ENTRY --sign csr --csr mycsr.csr -w /path/to/webroot/a.com/"5207 _usage "Usage: $PROJECT_ENTRY --sign-csr --csr <csr-file> --webroot <directory>" 4981 5208 return 1 4982 5209 fi … … 5046 5273 _csrd="$2" 5047 5274 if [ -z "$_csrfile" ] && [ -z "$_csrd" ]; then 5048 _usage "Usage: $PROJECT_ENTRY --show csr --csr mycsr.csr"5275 _usage "Usage: $PROJECT_ENTRY --show-csr --csr <csr-file>" 5049 5276 return 1 5050 5277 fi … … 5077 5304 } 5078 5305 5306 #listraw domain 5079 5307 list() { 5080 5308 _raw="$1" 5309 _domain="$2" 5081 5310 _initpath 5082 5311 5083 5312 _sep="|" 5084 5313 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 5086 5317 for di in "${CERT_HOME}"/*.*/; do 5087 5318 d=$(basename "$di") … … 5095 5326 if [ -f "$DOMAIN_CONF" ]; then 5096 5327 . "$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 5098 5336 fi 5099 5337 ) … … 5101 5339 else 5102 5340 if _exists column; then 5103 list "raw" | column -t -s "$_sep"5341 list "raw" "$_domain" | column -t -s "$_sep" 5104 5342 else 5105 list "raw" | tr "$_sep" '\t'5343 list "raw" "$_domain" | tr "$_sep" '\t' 5106 5344 fi 5107 5345 fi … … 5152 5390 _isEcc="$3" 5153 5391 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] " 5155 5393 return 1 5156 5394 fi … … 5173 5411 _main_domain="$1" 5174 5412 if [ -z "$_main_domain" ]; then 5175 _usage "Usage: $PROJECT_ENTRY --install cert -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>]" 5176 5414 return 1 5177 5415 fi … … 5231 5469 if [ "$_real_cert" ]; then 5232 5470 _info "Installing cert to:$_real_cert" 5233 if [ -f "$_real_cert" ] && [ ! "$ IS_RENEW" ]; then5471 if [ -f "$_real_cert" ] && [ ! "$_ACME_IS_RENEW" ]; then 5234 5472 cp "$_real_cert" "$_backup_path/cert.bak" 5235 5473 fi … … 5243 5481 cat "$CA_CERT_PATH" >>"$_real_ca" || return 1 5244 5482 else 5245 if [ -f "$_real_ca" ] && [ ! "$ IS_RENEW" ]; then5483 if [ -f "$_real_ca" ] && [ ! "$_ACME_IS_RENEW" ]; then 5246 5484 cp "$_real_ca" "$_backup_path/ca.bak" 5247 5485 fi … … 5252 5490 if [ "$_real_key" ]; then 5253 5491 _info "Installing key to:$_real_key" 5254 if [ -f "$_real_key" ] && [ ! "$ IS_RENEW" ]; then5492 if [ -f "$_real_key" ] && [ ! "$_ACME_IS_RENEW" ]; then 5255 5493 cp "$_real_key" "$_backup_path/key.bak" 5256 5494 fi … … 5265 5503 if [ "$_real_fullchain" ]; then 5266 5504 _info "Installing full chain to:$_real_fullchain" 5267 if [ -f "$_real_fullchain" ] && [ ! "$ IS_RENEW" ]; then5505 if [ -f "$_real_fullchain" ] && [ ! "$_ACME_IS_RENEW" ]; then 5268 5506 cp "$_real_fullchain" "$_backup_path/fullchain.bak" 5269 5507 fi … … 5448 5686 } 5449 5687 5688 #domain isECC revokeReason 5450 5689 revoke() { 5451 5690 Le_Domain="$1" 5452 5691 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]" 5454 5693 return 1 5455 5694 fi 5456 5695 5457 5696 _isEcc="$2" 5458 5697 _reason="$3" 5698 if [ -z "$_reason" ]; then 5699 _reason="0" 5700 fi 5459 5701 _initpath "$Le_Domain" "$_isEcc" 5460 5702 if [ ! -f "$DOMAIN_CONF" ]; then … … 5478 5720 5479 5721 if [ "$ACME_VERSION" = "2" ]; then 5480 data="{\"certificate\": \"$cert\" }"5722 data="{\"certificate\": \"$cert\",\"reason\":$_reason}" 5481 5723 else 5482 5724 data="{\"resource\": \"revoke-cert\", \"certificate\": \"$cert\"}" … … 5497 5739 fi 5498 5740 else 5499 _info "Domain key file doesn't exist s."5741 _info "Domain key file doesn't exist." 5500 5742 fi 5501 5743 … … 5519 5761 Le_Domain="$1" 5520 5762 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]" 5522 5764 return 1 5523 5765 fi … … 5596 5838 fi 5597 5839 5598 entries="$(echo "$response" | _egrep_o "{ *\"type\":\"[^\"]*\", *\"status\": *\"valid\", *\"$_URL_NAME\"[^}]*")"5840 entries="$(echo "$response" | tr '][' '==' | _egrep_o "challenges\": *=[^=]*=" | tr '}{' '\n' | grep "\"status\": *\"valid\"")" 5599 5841 if [ -z "$entries" ]; then 5600 5842 _info "No valid entries found." … … 5639 5881 _info "Found $_vtype" 5640 5882 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-)" 5642 5884 _debug uri "$uri" 5643 5885 … … 5679 5921 _debug _d_domain_list "$_d_domain_list" 5680 5922 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> ...]" 5682 5924 return 1 5683 5925 fi … … 5878 6120 fi 5879 6121 5880 if [ "$ ACME_IN_CRON" != "1" ]; then6122 if [ "$_ACME_IN_CRON" != "1" ]; then 5881 6123 if ! _precheck "$_nocron"; then 5882 6124 _err "Pre-check failed, can not install." … … 5935 6177 _info "Installed to $LE_WORKING_DIR/$PROJECT_ENTRY" 5936 6178 5937 if [ "$ ACME_IN_CRON" != "1" ] && [ -z "$_noprofile" ]; then6179 if [ "$_ACME_IN_CRON" != "1" ] && [ -z "$_noprofile" ]; then 5938 6180 _installalias "$_c_home" 5939 6181 fi … … 6033 6275 6034 6276 cron() { 6035 export ACME_IN_CRON=16277 export _ACME_IN_CRON=1 6036 6278 _initpath 6037 6279 _info "$(__green "===Starting cron===")" … … 6054 6296 renewAll 6055 6297 _ret="$?" 6056 ACME_IN_CRON=""6298 _ACME_IN_CRON="" 6057 6299 _info "$(__green "===End cron===")" 6058 6300 exit $_ret … … 6139 6381 6140 6382 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>]" 6142 6384 _usage "$_NOTIFY_WIKI" 6143 6385 return 1 … … 6178 6420 _initpath 6179 6421 version 6180 echo "Usage: $PROJECT_ENTRY command ...[parameters]....6422 echo "Usage: $PROJECT_ENTRY <command> ... [parameters ...] 6181 6423 Commands: 6182 - -help, -hShow this help message.6183 - -version, -vShow version info.6424 -h, --help Show this help message. 6425 -v, --version Show version info. 6184 6426 --install Install $PROJECT_NAME to your system. 6185 6427 --uninstall Uninstall $PROJECT_NAME, and uninstall the cron job. 6186 6428 --upgrade Upgrade $PROJECT_NAME to the latest code from $PROJECT. 6187 6429 --issue Issue a cert. 6188 --signcsr Issue a cert from an existing csr.6189 6430 --deploy Deploy the cert to your server. 6190 - -install-certInstall the issued cert to apache/nginx or any other server.6191 - -renew, -rRenew a cert.6431 -i, --install-cert Install the issued cert to apache/nginx or any other server. 6432 -r, --renew Renew a cert. 6192 6433 --renew-all Renew all the certs. 6193 6434 --revoke Revoke a cert. 6194 6435 --remove Remove the cert from list of certs known to $PROJECT_NAME. 6195 6436 --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. 6202 6443 --update-account Update account info. 6203 6444 --register-account Register account key. 6204 6445 --deactivate-account Deactivate the account. 6205 6446 --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. 6208 6451 --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 6210 6454 6211 6455 6212 6456 Parameters: 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. 6221 6474 --standalone Use standalone mode. 6222 6475 --alpn Use standalone alpn mode. 6223 --stateless Use stateless mode, see: $_STATELESS_WIKI 6476 --stateless Use stateless mode. 6477 See: $_STATELESS_WIKI 6478 6224 6479 --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 6233 6493 6234 6494 These parameters are to install the cert to nginx/apache or any other server after issue/renew a cert: 6235 6495 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. 6255 6516 --listraw Only used for '--list' command, list the certs in raw format. 6256 - -stopRenewOnError, -seOnly 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. 6257 6518 --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. 6261 6523 --noprofile Only valid for '--install' command, which means: do not install aliases to user profile. 6262 6524 --no-color Do not output color text. 6263 6525 --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', '--to Pkcs' and '--createCSR'6265 --csr 6266 --pre-hook 6267 --post-hook Command to be run after attempting to obtain/renew certificates. No matter the obtain/renew is successor failed.6268 --renew-hook Command to be run once for each successfully renewed certificate.6269 --deploy-hook 6270 --ocsp -must-staple, --ocsp Generate ocsp mustStaple 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. 6273 6535 --listen-v4 Force standalone/tls server to listen at ipv4. 6274 6536 --listen-v6 Force standalone/tls server to listen at ipv6. 6275 --openssl-bin 6537 --openssl-bin <file> Specifies a custom openssl bin location. 6276 6538 --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 6289 6557 6290 6558 " … … 6319 6587 _info "Install success!" 6320 6588 _initpath 6321 _saveaccountconf "UPGRADE_HASH" "$(_get MasterHash)"6589 _saveaccountconf "UPGRADE_HASH" "$(_getUpgradeHash)" 6322 6590 fi 6323 6591 … … 6329 6597 } 6330 6598 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() { 6332 6607 _b="$BRANCH" 6333 6608 if [ -z "$_b" ]; then 6334 6609 _b="master" 6335 6610 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 6338 6614 } 6339 6615 … … 6341 6617 if ( 6342 6618 _initpath 6343 [ -z "$FORCE" ] && [ "$(_get MasterHash)" = "$(_readaccountconf "UPGRADE_HASH")" ] && _info "Already uptodate!" && exit 06619 [ -z "$FORCE" ] && [ "$(_getUpgradeHash)" = "$(_readaccountconf "UPGRADE_HASH")" ] && _info "Already uptodate!" && exit 0 6344 6620 export LE_WORKING_DIR 6345 6621 cd "$LE_WORKING_DIR" … … 6361 6637 fi 6362 6638 6363 if [ "$_accountemail" ]; then6364 _saveaccountconf "ACCOUNT_EMAIL" "$_accountemail"6365 elif [ "$ACCOUNT_EMAIL" ] && [ "$ACCOUNT_EMAIL" != "$DEFAULT_ACCOUNT_EMAIL" ]; then6366 _saveaccountconf "ACCOUNT_EMAIL" "$ACCOUNT_EMAIL"6367 fi6368 6369 6639 if [ "$_openssl_bin" ]; then 6370 6640 _saveaccountconf "ACME_OPENSSL_BIN" "$_openssl_bin" … … 6393 6663 return 0 6394 6664 fi 6395 if [ "$SUDO_COMMAND" = "/bin/su" ] || [ "$SUDO_COMMAND" = "/bin/bash" ]; then6396 #it's a normal user doing "sudo su", or `sudo -i` or `sudo -s` 6397 #fine6398 return 06665 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 $? 6399 6669 fi 6400 6670 #otherwise … … 6402 6672 fi 6403 6673 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 6725 setdefaultca() { 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")" 6404 6732 } 6405 6733 … … 6454 6782 _notify_level="" 6455 6783 _notify_mode="" 6784 _revoke_reason="" 6785 _eab_kid="" 6786 _eab_hmac_key="" 6787 _preferred_chain="" 6456 6788 while [ ${#} -gt 0 ]; do 6457 6789 case "${1}" in 6458 6790 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" 6564 6902 else 6565 if [ "$_altdomains" = "$NO_VALUE" ]; then 6566 _altdomains="$_dvalue" 6567 else 6568 _altdomains="$_altdomains,$_dvalue" 6569 fi 6903 _altdomains="$_altdomains,$_dvalue" 6570 6904 fi 6571 6905 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" 6573 6927 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" 6586 6993 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 6600 7004 wvalue="$2" 6601 if [ -z "$_webroot" ]; then6602 _webroot="$wvalue"6603 else6604 _webroot="$_webroot,$wvalue"6605 fi6606 7005 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" 6611 7168 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 6616 7180 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" 6645 7195 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 6682 7206 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'" 6930 7235 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 ;; 6932 7286 esac 6933 7287 … … 6988 7342 _debug "Running cmd: ${_CMD}" 6989 7343 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 ;; 7063 7420 esac 7064 7421 _ret="$?" -
npl/syn3/acme/root/usr/bin/syn3-acme-issue
r30f002a r6e9c61f 5 5 6 6 echo "SYN-3: Issueing TEST certificate" 7 if syn3-acme --config-home /etc/acme/test -- test --issue --standalone $DOMAINS $@; then7 if syn3-acme --config-home /etc/acme/test --force --test --issue --standalone $DOMAINS $@; then 8 8 echo "SYN-3: Issueing LIVE certificate" 9 9 syn3-acme --config-home /etc/acme/live --issue --standalone --fullchain-file /usr/webint/ssl/server.crt --key-file /usr/webint/ssl/server.pem $DOMAINS $@ … … 15 15 16 16 if [ "$EXIT" == "0" ]; then 17 cat /usr/webint/ssl/server.crt /usr/webint/ssl/server.key > /usr/webint/ssl/certandkey.pem 17 18 syn3-state certbot OK "SSL certificate valid." 18 19 fi 19 20 21 20 22 exit $EXIT -
npl/syn3/acme/root/usr/bin/syn3-acme-renew
r30f002a r6e9c61f 15 15 16 16 if [ "$EXIT" == "0" ]; then 17 cat /usr/webint/ssl/server.crt /usr/webint/ssl/server.key > /usr/webint/ssl/certandkey.pem 17 18 syn3-state certbot OK "SSL certificate valid. `cat $STATUS`" 18 19 else -
npl/syn3/acme/syn3_acme.build
r30f002a r6e9c61f 1 9 1 10 -
npl/syn3/acme/syn3_acme.md5
r30f002a r6e9c61f 1 1 d41d8cd98f00b204e9800998ecf8427e ./root/etc/webint/SSL_DOMAINS.new 2 9215d7b19618c71a42df9326d86ad16f./root/usr/bin/acme.sh2 0418c2dac1c09a1e0a5a923de7155251 ./root/usr/bin/acme.sh 3 3 a0e5403f61c08e4eda04cd2e61d7938a ./root/usr/bin/syn3-acme 4 cb7232508745b67caad455dd54cd8bb9./root/usr/bin/syn3-acme-issue5 f5eca94149edc261a950c497533c71a2./root/usr/bin/syn3-acme-renew6 fe2fd64e8e4592834c27d7978aebcde4./syn3_acme.pkg4 59aa594e0d86791b3aa9b7b1a3e88e42 ./root/usr/bin/syn3-acme-issue 5 917bbc278f45bd8ab36a946d4898dd0f ./root/usr/bin/syn3-acme-renew 6 0301b5ee1cb78f1410fe47edbf32e780 ./syn3_acme.pkg 7 7 1a66f2a0cb707f264b0268ee3d4956d3 ./syn3_acme.SlackBuild 8 556f9498697435671507e661abe96a95./syn3_acme.SlackBuild.log.gz8 6c17d788610977961a07f821dad6ccc3 ./syn3_acme.SlackBuild.log.gz
Note: See TracChangeset
for help on using the changeset viewer.