Changeset 105afb5
- Timestamp:
- 11/29/21 12:16:54 (3 years ago)
- Branches:
- master
- Children:
- 439f083
- Parents:
- 7c410f9
- Location:
- npl
- Files:
-
- 7 added
- 7 deleted
- 30 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
npl/overig/curl/curl.SlackBuild
r7c410f9 r105afb5 2 2 # 3 3 # Automaticly created by importpackage v1.0 4 # Imported from: http ://mirrors.slackware.com/slackware/slackware-current/source/n/curl/5 # Created at Thu Oct 13 15:04:31 CEST 20164 # Imported from: https://mirrors.slackware.com/slackware/slackware-current/source/n/curl/ 5 # Created at ma 29 nov 2021 11:59:09 CET 6 6 #DEP:openssl 7 7 -
npl/overig/curl/curl.SlackBuild.orig
r7c410f9 r105afb5 1 #!/bin/ sh1 #!/bin/bash 2 2 3 # Copyright 2008, 2009, 2010, 2011, 2013, 2014, 2016 Patrick J. Volkerding, Sebeka, MN, USA3 # Copyright 2008, 2009, 2010, 2011, 2013, 2014, 2016, 2017, 2018, 2020, 2021 Patrick J. Volkerding, Sebeka, MN, USA 4 4 # All rights reserved. 5 5 # … … 21 21 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 22 23 cd $(dirname $0) ; CWD=$(pwd) 23 24 24 25 PKGNAM=curl 25 VERSION=${VERSION:-$(echo curl-*.tar. bz2| rev | cut -f 3- -d . | cut -f 1 -d - | rev)}26 VERSION=${VERSION:-$(echo curl-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} 26 27 BUILD=${BUILD:-1} 27 28 … … 36 37 fi 37 38 38 NUMJOBS=${NUMJOBS:-" -j7 "} 39 # If the variable PRINT_PACKAGE_NAME is set, then this script will report what 40 # the name of the created package would be, and then exit. This information 41 # could be useful to other scripts. 42 if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then 43 echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" 44 exit 0 45 fi 39 46 40 CWD=$(pwd) 47 NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "} 48 41 49 TMP=${TMP:-/tmp} 42 50 PKG=$TMP/package-curl 43 51 44 # Uncommentto build a no-SSL version:45 #SSLOPT=--without-ssl 52 # Set this variable to "--without-ssl" to build a no-SSL version: 53 SSLOPT=${SSLOPT:-"--with-openssl"} 46 54 47 55 if [ "$ARCH" = "i586" ]; then … … 63 71 cd $TMP 64 72 rm -rf curl-$VERSION 65 tar xvf $CWD/curl-$VERSION.tar. bz2|| exit 166 cd curl-$VERSION 73 tar xvf $CWD/curl-$VERSION.tar.xz || exit 1 74 cd curl-$VERSION || exit 1 67 75 68 76 chown -R root:root . 69 77 find . \ 70 78 \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ 71 -exec chmod 755 {} \ ;-o \79 -exec chmod 755 {} \+ -o \ 72 80 \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ 73 -exec chmod 644 {} \ ;81 -exec chmod 644 {} \+ 74 82 75 83 CFLAGS="$SLKCFLAGS" \ … … 78 86 --libdir=/usr/lib${LIBDIRSUFFIX} \ 79 87 --mandir=/usr/man \ 80 --with- ca-bundle=/usr/share/curl/ca-bundle.crt\88 --with-gssapi \ 81 89 --enable-static=no \ 82 $SSLOPT 90 --without-ca-bundle \ 91 --with-ca-path=/etc/ssl/certs \ 92 $SSLOPT || exit 1 83 93 84 94 make $NUMJOBS || make || exit 1 85 95 make install DESTDIR=$PKG || exit 1 86 96 87 mkdir -p $PKG/usr/share/curl 88 cp -a $CWD/cacert.pem.bz2 $PKG/usr/share/curl 89 ( cd $PKG/usr/share/curl 90 bzip2 -d cacert.pem.bz2 91 mv cacert.pem ca-bundle.crt 92 chown root:root ca-bundle.crt 93 chmod 644 ca-bundle.crt 97 # Don't ship .la files: 98 rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la 99 100 # We have always installed the man3 documentation, so we'll keep doing it 101 # even though these are no longer installed by default. No || exit 1, if 102 # it works, it works, and if it doesn't, we tried. 103 ( cd docs/libcurl 104 make install-man3 DESTDIR=$PKG 105 cd opts 106 make install-man3 DESTDIR=$PKG 94 107 ) 95 108 … … 104 117 mkdir -p $PKG/usr/doc/curl-$VERSION 105 118 cp -a \ 106 COPYING* README* \119 COPYING* README* \ 107 120 $PKG/usr/doc/curl-$VERSION 108 ( cd docs109 rm -rf Makefile* curl-config.1 curl-config.html curl.1 curl.html libcurl110 cp -a \111 BUGS FAQ FEATURES INSTALL MANUAL README* RESOURCES THANKS TODO examples \112 $PKG/usr/doc/curl-$VERSION )113 121 # Get rid of .deps cruft: 114 rm -rf $PKG/usr/doc/curl-$VERSION/examples/.deps 122 rm -rf $PKG/usr/doc/curl-$VERSION/examples/.deps || true 115 123 116 124 # If there's a CHANGES file, installing at least part of the recent history -
npl/overig/curl/curl.build
r7c410f9 r105afb5 1 6526 1 6527 2 -
npl/overig/curl/curl.md5
r7c410f9 r105afb5 1 6a26088131084de88249d18c712efe22 ./cacert-fetch.sh 2 de25f1a2e0fe6347cbc1b8cf15fb5235 ./cacert.pem.bz2 3 bd177fd6deecce00cfa7b5916d831c5e ./curl-7.50.3.tar.bz2 4 8280845acce7ce9a0d86d2d56f6cb7ed ./curl-7.50.3.tar.bz2.asc 5 39c7a420f62ededda8fb99dfda559ae7 ./curl_dev.pkg 6 3874608d5935cc4fc98ddf66af5b68d8 ./curl.pkg 7 a2b9ad44cbfffc395e9659aaa54f15fa ./curl.SlackBuild 8 c6b669414601bbf65ae4e70f3963f38d ./curl.SlackBuild.log.gz 9 c5aaf1f564f36d3e644b1cfa78d65d25 ./curl.SlackBuild.orig 10 57ca4674cb7b3f61a5368f03c762b298 ./slack-desc 1 cf9f8553762150ef0ebcd5ee412737f5 ./curl-7.80.0.tar.xz 2 acdfa1afa53bc2b3860890fe56164400 ./curl-7.80.0.tar.xz.asc 3 7a91c1763505d6ab1838b080cda02479 ./curl_dev.pkg 4 d1c96ad6fda1e0a5c72af6704f1c518e ./curl.pkg 5 d7cfd54cbf5d2e6530bd4d0d11d41f6b ./curl.SlackBuild 6 0deec8e8a5ad982c5ca4ba26559da236 ./curl.SlackBuild.log.gz 7 f4e145d65c8e5699c6aee62d6202b911 ./curl.SlackBuild.orig 8 e5ca7d0aa9057708c065f7dee5c43ed6 ./curl.url 9 c722a231538a9f14d2335d36231f0c9b ./slack-desc -
npl/overig/curl/curl.version
r7c410f9 r105afb5 1 7. 50.31 7.80.0 -
npl/overig/curl/curl_dev.build
r7c410f9 r105afb5 1 652 61 6527 -
npl/overig/curl/curl_dev.version
r7c410f9 r105afb5 1 7. 50.31 7.80.0 -
npl/overig/curl/slack-desc
r7c410f9 r105afb5 1 1 # HOW TO EDIT THIS FILE: 2 # The "handy ruler" below makes it easier to edit a package description. 2 # The "handy ruler" below makes it easier to edit a package description. Line 3 3 # up the first '|' above the ':' following the base package name, and the '|' 4 # on the right side marks the last column you can put a character in. 5 # make exactly 11 lines for the formatting to be correct. 4 # on the right side marks the last column you can put a character in. You must 5 # make exactly 11 lines for the formatting to be correct. It's also 6 6 # customary to leave one space after the ':'. 7 7 … … 10 10 curl: 11 11 curl: Curl is a command line tool for transferring data specified with URL 12 curl: syntax. 13 curl: any kind of interactivity. 12 curl: syntax. The command is designed to work without user interaction or 13 curl: any kind of interactivity. Curl offers a busload of useful tricks 14 14 curl: like proxy support, user authentication, ftp upload, HTTP post, SSL 15 15 curl: (https:) connections, cookies, file transfer resume and more. -
npl/syn3/acme/root/usr/bin/acme.sh
r7c410f9 r105afb5 1 1 #!/usr/bin/env sh 2 2 3 VER= 2.8.83 VER=3.0.1 4 4 5 5 PROJECT_NAME="acme.sh" … … 21 21 _SUB_FOLDERS="$_SUB_FOLDER_DNSAPI $_SUB_FOLDER_DEPLOY $_SUB_FOLDER_NOTIFY" 22 22 23 LETSENCRYPT_CA_V1="https://acme-v01.api.letsencrypt.org/directory" 24 LETSENCRYPT_STAGING_CA_V1="https://acme-staging.api.letsencrypt.org/directory" 23 CA_LETSENCRYPT_V1="https://acme-v01.api.letsencrypt.org/directory" 25 24 26 25 CA_LETSENCRYPT_V2="https://acme-v02.api.letsencrypt.org/directory" … … 33 32 _ZERO_EAB_ENDPOINT="http://api.zerossl.com/acme/eab-credentials-email" 34 33 35 DEFAULT_CA=$CA_LETSENCRYPT_V2 34 CA_SSLCOM_RSA="https://acme.ssl.com/sslcom-dv-rsa" 35 CA_SSLCOM_ECC="https://acme.ssl.com/sslcom-dv-ecc" 36 37 DEFAULT_CA=$CA_ZEROSSL 36 38 DEFAULT_STAGING_CA=$CA_LETSENCRYPT_V2_TEST 37 39 38 40 CA_NAMES=" 41 ZeroSSL.com,zerossl 39 42 LetsEncrypt.org,letsencrypt 40 43 LetsEncrypt.org_test,letsencrypt_test,letsencrypttest 41 44 BuyPass.com,buypass 42 45 BuyPass.com_test,buypass_test,buypasstest 43 ZeroSSL.com,zerossl 46 SSL.com,sslcom 44 47 " 45 48 46 CA_SERVERS="$CA_ LETSENCRYPT_V2,$CA_LETSENCRYPT_V2_TEST,$CA_BUYPASS,$CA_BUYPASS_TEST,$CA_ZEROSSL"49 CA_SERVERS="$CA_ZEROSSL,$CA_LETSENCRYPT_V2,$CA_LETSENCRYPT_V2_TEST,$CA_BUYPASS,$CA_BUYPASS_TEST,$CA_SSLCOM_RSA" 47 50 48 51 DEFAULT_USER_AGENT="$PROJECT_NAME/$VER ($PROJECT)" … … 103 106 DOH_CLOUDFLARE=1 104 107 DOH_GOOGLE=2 108 DOH_ALI=3 109 DOH_DP=4 105 110 106 111 HIDDEN_VALUE="[hidden](please add '--output-insecure' to see this value)" … … 157 162 _ZEROSSL_WIKI="https://github.com/acmesh-official/acme.sh/wiki/ZeroSSL.com-CA" 158 163 164 _SSLCOM_WIKI="https://github.com/acmesh-official/acme.sh/wiki/SSL.com-CA" 165 159 166 _SERVER_WIKI="https://github.com/acmesh-official/acme.sh/wiki/Server" 160 167 161 168 _PREFERRED_CHAIN_WIKI="https://github.com/acmesh-official/acme.sh/wiki/Preferred-Chain" 169 170 _DNSCHECK_WIKI="https://github.com/acmesh-official/acme.sh/wiki/dnscheck" 162 171 163 172 _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." … … 561 570 562 571 _h2b() { 563 if _exists xxd && xxd -r -p 2>/dev/null; then 564 return 572 if _exists xxd; then 573 if _contains "$(xxd --help 2>&1)" "assumes -c30"; then 574 if xxd -r -p -c 9999 2>/dev/null; then 575 return 576 fi 577 else 578 if xxd -r -p 2>/dev/null; then 579 return 580 fi 581 fi 565 582 fi 566 583 … … 1123 1140 if _isEccKey "$length"; then 1124 1141 _debug "Using ec name: $eccname" 1125 if _opkey="$(${ACME_OPENSSL_BIN:-openssl} ecparam -name "$eccname" - genkey 2>/dev/null)"; then1142 if _opkey="$(${ACME_OPENSSL_BIN:-openssl} ecparam -name "$eccname" -noout -genkey 2>/dev/null)"; then 1126 1143 echo "$_opkey" >"$f" 1127 1144 else … … 1131 1148 else 1132 1149 _debug "Using RSA: $length" 1133 if _opkey="$(${ACME_OPENSSL_BIN:-openssl} genrsa "$length" 2>/dev/null)"; then 1150 __traditional="" 1151 if _contains "$(${ACME_OPENSSL_BIN:-openssl} help genrsa 2>&1)" "-traditional"; then 1152 __traditional="-traditional" 1153 fi 1154 if _opkey="$(${ACME_OPENSSL_BIN:-openssl} genrsa $__traditional "$length" 2>/dev/null)"; then 1134 1155 echo "$_opkey" >"$f" 1135 1156 else … … 1198 1219 _debug2 csrconf "$csrconf" 1199 1220 1200 printf "[ req_distinguished_name ]\n[ req ]\ndistinguished_name = req_distinguished_name\nreq_extensions = v3_req\n[ v3_req ]\n\n keyUsage = nonRepudiation, digitalSignature, keyEncipherment" >"$csrconf"1221 printf "[ req_distinguished_name ]\n[ req ]\ndistinguished_name = req_distinguished_name\nreq_extensions = v3_req\n[ v3_req ]\n\n" >"$csrconf" 1201 1222 1202 1223 if [ "$acmeValidationv1" ]; then … … 1750 1771 _ACME_CURL="$_ACME_CURL -L " 1751 1772 fi 1752 if [ "$DEBUG" ] && [ "$DEBUG" -ge "2"]; then1773 if [ "$DEBUG" ] && [ "$DEBUG" -ge 2 ]; then 1753 1774 _CURL_DUMP="$(_mktemp)" 1754 1775 _ACME_CURL="$_ACME_CURL --trace-ascii $_CURL_DUMP " … … 1789 1810 1790 1811 } 1812 1813 _HTTP_MAX_RETRY=8 1791 1814 1792 1815 # body url [needbase64] [POST|PUT|DELETE] [ContentType] … … 1797 1820 httpmethod="$4" 1798 1821 _postContentType="$5" 1822 _sleep_retry_sec=1 1823 _http_retry_times=0 1824 _hcode=0 1825 while [ "${_http_retry_times}" -le "$_HTTP_MAX_RETRY" ]; do 1826 [ "$_http_retry_times" = "$_HTTP_MAX_RETRY" ] 1827 _lastHCode="$?" 1828 _debug "Retrying post" 1829 _post_impl "$body" "$_post_url" "$needbase64" "$httpmethod" "$_postContentType" "$_lastHCode" 1830 _hcode="$?" 1831 _debug _hcode "$_hcode" 1832 if [ "$_hcode" = "0" ]; then 1833 break 1834 fi 1835 _http_retry_times=$(_math $_http_retry_times + 1) 1836 _sleep $_sleep_retry_sec 1837 done 1838 return $_hcode 1839 } 1840 1841 # body url [needbase64] [POST|PUT|DELETE] [ContentType] [displayError] 1842 _post_impl() { 1843 body="$1" 1844 _post_url="$2" 1845 needbase64="$3" 1846 httpmethod="$4" 1847 _postContentType="$5" 1848 displayError="$6" 1799 1849 1800 1850 if [ -z "$httpmethod" ]; then … … 1848 1898 _ret="$?" 1849 1899 if [ "$_ret" != "0" ]; then 1850 _err "Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: $_ret" 1900 if [ -z "$displayError" ] || [ "$displayError" = "0" ]; then 1901 _err "Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: $_ret" 1902 fi 1851 1903 if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ]; then 1852 1904 _err "Here is the curl dump log:" … … 1904 1956 fi 1905 1957 if [ "$_ret" != "0" ]; then 1906 _err "Please refer to https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html for error code: $_ret" 1958 if [ -z "$displayError" ] || [ "$displayError" = "0" ]; then 1959 _err "Please refer to https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html for error code: $_ret" 1960 fi 1907 1961 fi 1908 1962 _sed_i "s/^ *//g" "$HTTP_HEADER" … … 1918 1972 # url getheader timeout 1919 1973 _get() { 1974 url="$1" 1975 onlyheader="$2" 1976 t="$3" 1977 _sleep_retry_sec=1 1978 _http_retry_times=0 1979 _hcode=0 1980 while [ "${_http_retry_times}" -le "$_HTTP_MAX_RETRY" ]; do 1981 [ "$_http_retry_times" = "$_HTTP_MAX_RETRY" ] 1982 _lastHCode="$?" 1983 _debug "Retrying GET" 1984 _get_impl "$url" "$onlyheader" "$t" "$_lastHCode" 1985 _hcode="$?" 1986 _debug _hcode "$_hcode" 1987 if [ "$_hcode" = "0" ]; then 1988 break 1989 fi 1990 _http_retry_times=$(_math $_http_retry_times + 1) 1991 _sleep $_sleep_retry_sec 1992 done 1993 return $_hcode 1994 } 1995 1996 # url getheader timeout displayError 1997 _get_impl() { 1920 1998 _debug GET 1921 1999 url="$1" 1922 2000 onlyheader="$2" 1923 2001 t="$3" 2002 displayError="$4" 1924 2003 _debug url "$url" 1925 2004 _debug "timeout=$t" 1926 2005 _debug "displayError" "$displayError" 1927 2006 _inithttp 1928 2007 … … 1943 2022 ret=$? 1944 2023 if [ "$ret" != "0" ]; then 1945 _err "Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: $ret" 2024 if [ -z "$displayError" ] || [ "$displayError" = "0" ]; then 2025 _err "Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: $ret" 2026 fi 1946 2027 if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ]; then 1947 2028 _err "Here is the curl dump log:" … … 1969 2050 fi 1970 2051 if [ "$ret" != "0" ]; then 1971 _err "Please refer to https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html for error code: $ret" 2052 if [ -z "$displayError" ] || [ "$displayError" = "0" ]; then 2053 _err "Please refer to https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html for error code: $ret" 2054 fi 1972 2055 fi 1973 2056 else … … 2025 2108 _headers="$(cat "$HTTP_HEADER")" 2026 2109 _debug2 _headers "$_headers" 2027 _CACHED_NONCE="$(echo "$_headers" | grep -i "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2 )"2110 _CACHED_NONCE="$(echo "$_headers" | grep -i "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2 | cut -d , -f 1)" 2028 2111 fi 2029 2112 fi … … 2057 2140 continue 2058 2141 fi 2059 if [ "$ACME_VERSION" = "2" ]; then 2060 if [ "$url" = "$ACME_NEW_ACCOUNT" ]; then 2061 protected="$JWK_HEADERPLACE_PART1$nonce\", \"url\": \"${url}$JWK_HEADERPLACE_PART2, \"jwk\": $jwk"'}' 2062 elif [ "$url" = "$ACME_REVOKE_CERT" ] && [ "$keyfile" != "$ACCOUNT_KEY_PATH" ]; then 2063 protected="$JWK_HEADERPLACE_PART1$nonce\", \"url\": \"${url}$JWK_HEADERPLACE_PART2, \"jwk\": $jwk"'}' 2064 else 2065 protected="$JWK_HEADERPLACE_PART1$nonce\", \"url\": \"${url}$JWK_HEADERPLACE_PART2, \"kid\": \"${ACCOUNT_URL}\""'}' 2066 fi 2142 2143 if [ "$url" = "$ACME_NEW_ACCOUNT" ]; then 2144 protected="$JWK_HEADERPLACE_PART1$nonce\", \"url\": \"${url}$JWK_HEADERPLACE_PART2, \"jwk\": $jwk"'}' 2145 elif [ "$url" = "$ACME_REVOKE_CERT" ] && [ "$keyfile" != "$ACCOUNT_KEY_PATH" ]; then 2146 protected="$JWK_HEADERPLACE_PART1$nonce\", \"url\": \"${url}$JWK_HEADERPLACE_PART2, \"jwk\": $jwk"'}' 2067 2147 else 2068 protected="$JWK_HEADERPLACE_PART1$nonce\", \"url\": \"${url}$JWK_HEADERPLACE_PART2, \"jwk\": $jwk"'}' 2069 fi 2148 protected="$JWK_HEADERPLACE_PART1$nonce\", \"url\": \"${url}$JWK_HEADERPLACE_PART2, \"kid\": \"${ACCOUNT_URL}\""'}' 2149 fi 2150 2070 2151 _debug3 protected "$protected" 2071 2152 … … 2105 2186 _debug2 response "$response" 2106 2187 2107 _CACHED_NONCE="$(echo "$responseHeaders" | grep -i "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2 )"2188 _CACHED_NONCE="$(echo "$responseHeaders" | grep -i "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2 | cut -d , -f 1)" 2108 2189 2109 2190 if ! _startswith "$code" "2"; then … … 2116 2197 if _contains "$_body" "JWS has invalid anti-replay nonce" || _contains "$_body" "JWS has an invalid anti-replay nonce"; then 2117 2198 _info "It seems the CA server is busy now, let's wait and retry. Sleeping $_sleep_retry_sec seconds." 2199 _CACHED_NONCE="" 2200 _sleep $_sleep_retry_sec 2201 continue 2202 fi 2203 if _contains "$_body" "The Replay Nonce is not recognized"; then 2204 _info "The replay Nonce is not valid, let's get a new one, Sleeping $_sleep_retry_sec seconds." 2118 2205 _CACHED_NONCE="" 2119 2206 _sleep $_sleep_retry_sec … … 2247 2334 fi 2248 2335 _saved=$(_readdomainconf "SAVED_$_rac_key") 2249 eval "export $_rac_key=\" $_saved\""2336 eval "export $_rac_key=\"\$_saved\"" 2250 2337 } 2251 2338 … … 2276 2363 _clearaccountconf() { 2277 2364 _clear_conf "$ACCOUNT_CONF_PATH" "$1" 2365 } 2366 2367 #key 2368 _clearaccountconf_mutable() { 2369 _clearaccountconf "SAVED_$1" 2370 #remove later 2371 _clearaccountconf "$1" 2278 2372 } 2279 2373 … … 2331 2425 echo 'Content-Length\: $_content_len'; \ 2332 2426 echo ''; \ 2333 printf --'$content';" &2427 printf '%s' '$content';" & 2334 2428 serverproc="$!" 2335 2429 } … … 2506 2600 } 2507 2601 2602 _clearAPI() { 2603 ACME_NEW_ACCOUNT="" 2604 ACME_KEY_CHANGE="" 2605 ACME_NEW_AUTHZ="" 2606 ACME_NEW_ORDER="" 2607 ACME_REVOKE_CERT="" 2608 ACME_NEW_NONCE="" 2609 ACME_AGREEMENT="" 2610 } 2611 2508 2612 #server 2509 2613 _initAPI() { … … 2511 2615 _debug "_init api for server: $_api_server" 2512 2616 2513 if [ -z "$ACME_NEW_ACCOUNT" ]; then 2617 MAX_API_RETRY_TIMES=10 2618 _sleep_retry_sec=10 2619 _request_retry_times=0 2620 while [ -z "$ACME_NEW_ACCOUNT" ] && [ "${_request_retry_times}" -lt "$MAX_API_RETRY_TIMES" ]; do 2621 _request_retry_times=$(_math "$_request_retry_times" + 1) 2514 2622 response=$(_get "$_api_server") 2515 2623 if [ "$?" != "0" ]; then 2516 2624 _debug2 "response" "$response" 2517 _err "Can not init api." 2518 return 1 2625 _info "Can not init api for: $_api_server." 2626 _info "Sleep $_sleep_retry_sec and retry." 2627 _sleep "$_sleep_retry_sec" 2628 continue 2519 2629 fi 2520 2630 response=$(echo "$response" | _json_decode) 2521 2631 _debug2 "response" "$response" 2522 2632 2523 ACME_KEY_CHANGE=$(echo "$response" | _egrep_o 'key-change" *: *"[^"]*"' | cut -d '"' -f 3) 2524 if [ -z "$ACME_KEY_CHANGE" ]; then 2525 ACME_KEY_CHANGE=$(echo "$response" | _egrep_o 'keyChange" *: *"[^"]*"' | cut -d '"' -f 3) 2526 fi 2633 ACME_KEY_CHANGE=$(echo "$response" | _egrep_o 'keyChange" *: *"[^"]*"' | cut -d '"' -f 3) 2527 2634 export ACME_KEY_CHANGE 2528 2635 2529 ACME_NEW_AUTHZ=$(echo "$response" | _egrep_o 'new-authz" *: *"[^"]*"' | cut -d '"' -f 3) 2530 if [ -z "$ACME_NEW_AUTHZ" ]; then 2531 ACME_NEW_AUTHZ=$(echo "$response" | _egrep_o 'newAuthz" *: *"[^"]*"' | cut -d '"' -f 3) 2532 fi 2636 ACME_NEW_AUTHZ=$(echo "$response" | _egrep_o 'newAuthz" *: *"[^"]*"' | cut -d '"' -f 3) 2533 2637 export ACME_NEW_AUTHZ 2534 2638 2535 ACME_NEW_ORDER=$(echo "$response" | _egrep_o 'new-cert" *: *"[^"]*"' | cut -d '"' -f 3) 2536 ACME_NEW_ORDER_RES="new-cert" 2537 if [ -z "$ACME_NEW_ORDER" ]; then 2538 ACME_NEW_ORDER=$(echo "$response" | _egrep_o 'new-order" *: *"[^"]*"' | cut -d '"' -f 3) 2539 ACME_NEW_ORDER_RES="new-order" 2540 if [ -z "$ACME_NEW_ORDER" ]; then 2541 ACME_NEW_ORDER=$(echo "$response" | _egrep_o 'newOrder" *: *"[^"]*"' | cut -d '"' -f 3) 2542 fi 2543 fi 2639 ACME_NEW_ORDER=$(echo "$response" | _egrep_o 'newOrder" *: *"[^"]*"' | cut -d '"' -f 3) 2544 2640 export ACME_NEW_ORDER 2545 export ACME_NEW_ORDER_RES 2546 2547 ACME_NEW_ACCOUNT=$(echo "$response" | _egrep_o 'new-reg" *: *"[^"]*"' | cut -d '"' -f 3) 2548 ACME_NEW_ACCOUNT_RES="new-reg" 2549 if [ -z "$ACME_NEW_ACCOUNT" ]; then 2550 ACME_NEW_ACCOUNT=$(echo "$response" | _egrep_o 'new-account" *: *"[^"]*"' | cut -d '"' -f 3) 2551 ACME_NEW_ACCOUNT_RES="new-account" 2552 if [ -z "$ACME_NEW_ACCOUNT" ]; then 2553 ACME_NEW_ACCOUNT=$(echo "$response" | _egrep_o 'newAccount" *: *"[^"]*"' | cut -d '"' -f 3) 2554 if [ "$ACME_NEW_ACCOUNT" ]; then 2555 export ACME_VERSION=2 2556 fi 2557 fi 2558 fi 2641 2642 ACME_NEW_ACCOUNT=$(echo "$response" | _egrep_o 'newAccount" *: *"[^"]*"' | cut -d '"' -f 3) 2559 2643 export ACME_NEW_ACCOUNT 2560 export ACME_NEW_ACCOUNT_RES 2561 2562 ACME_REVOKE_CERT=$(echo "$response" | _egrep_o 'revoke-cert" *: *"[^"]*"' | cut -d '"' -f 3) 2563 if [ -z "$ACME_REVOKE_CERT" ]; then 2564 ACME_REVOKE_CERT=$(echo "$response" | _egrep_o 'revokeCert" *: *"[^"]*"' | cut -d '"' -f 3) 2565 fi 2644 2645 ACME_REVOKE_CERT=$(echo "$response" | _egrep_o 'revokeCert" *: *"[^"]*"' | cut -d '"' -f 3) 2566 2646 export ACME_REVOKE_CERT 2567 2647 2568 ACME_NEW_NONCE=$(echo "$response" | _egrep_o 'new-nonce" *: *"[^"]*"' | cut -d '"' -f 3) 2569 if [ -z "$ACME_NEW_NONCE" ]; then 2570 ACME_NEW_NONCE=$(echo "$response" | _egrep_o 'newNonce" *: *"[^"]*"' | cut -d '"' -f 3) 2571 fi 2648 ACME_NEW_NONCE=$(echo "$response" | _egrep_o 'newNonce" *: *"[^"]*"' | cut -d '"' -f 3) 2572 2649 export ACME_NEW_NONCE 2573 2650 2574 ACME_AGREEMENT=$(echo "$response" | _egrep_o 'terms-of-service" *: *"[^"]*"' | cut -d '"' -f 3) 2575 if [ -z "$ACME_AGREEMENT" ]; then 2576 ACME_AGREEMENT=$(echo "$response" | _egrep_o 'termsOfService" *: *"[^"]*"' | cut -d '"' -f 3) 2577 fi 2651 ACME_AGREEMENT=$(echo "$response" | _egrep_o 'termsOfService" *: *"[^"]*"' | cut -d '"' -f 3) 2578 2652 export ACME_AGREEMENT 2579 2653 … … 2585 2659 _debug "ACME_AGREEMENT" "$ACME_AGREEMENT" 2586 2660 _debug "ACME_NEW_NONCE" "$ACME_NEW_NONCE" 2587 _debug "ACME_VERSION" "$ACME_VERSION" 2588 2589 fi 2661 if [ "$ACME_NEW_ACCOUNT" ] && [ "$ACME_NEW_ORDER" ]; then 2662 return 0 2663 fi 2664 _info "Sleep $_sleep_retry_sec and retry." 2665 _sleep "$_sleep_retry_sec" 2666 done 2667 if [ "$ACME_NEW_ACCOUNT" ] && [ "$ACME_NEW_ORDER" ]; then 2668 return 0 2669 fi 2670 _err "Can not init api, for $_api_server" 2671 return 1 2590 2672 } 2591 2673 … … 2631 2713 _debug2 "_ACME_SERVER_HOST" "$_ACME_SERVER_HOST" 2632 2714 2633 CA_DIR="$CA_HOME/$_ACME_SERVER_HOST" 2634 2715 _ACME_SERVER_PATH="$(echo "$ACME_DIRECTORY" | cut -d : -f 2- | tr -s / | cut -d / -f 3-)" 2716 _debug2 "_ACME_SERVER_PATH" "$_ACME_SERVER_PATH" 2717 2718 CA_DIR="$CA_HOME/$_ACME_SERVER_HOST/$_ACME_SERVER_PATH" 2635 2719 _DEFAULT_CA_CONF="$CA_DIR/ca.conf" 2636 2637 2720 if [ -z "$CA_CONF" ]; then 2638 2721 CA_CONF="$_DEFAULT_CA_CONF" … … 2640 2723 _debug3 CA_CONF "$CA_CONF" 2641 2724 2642 if [ -f "$CA_CONF" ]; then 2643 . "$CA_CONF" 2644 fi 2645 2646 if [ -z "$ACME_DIR" ]; then 2647 ACME_DIR="/home/.acme" 2648 fi 2649 2650 if [ -z "$APACHE_CONF_BACKUP_DIR" ]; then 2651 APACHE_CONF_BACKUP_DIR="$LE_CONFIG_HOME" 2652 fi 2653 2654 if [ -z "$USER_AGENT" ]; then 2655 USER_AGENT="$DEFAULT_USER_AGENT" 2656 fi 2657 2658 if [ -z "$HTTP_HEADER" ]; then 2659 HTTP_HEADER="$LE_CONFIG_HOME/http.header" 2660 fi 2661 2662 _OLD_ACCOUNT_KEY="$LE_WORKING_DIR/account.key" 2663 _OLD_ACCOUNT_JSON="$LE_WORKING_DIR/account.json" 2725 _OLD_CADIR="$CA_HOME/$_ACME_SERVER_HOST" 2726 _OLD_ACCOUNT_KEY="$_OLD_CADIR/account.key" 2727 _OLD_ACCOUNT_JSON="$_OLD_CADIR/account.json" 2728 _OLD_CA_CONF="$_OLD_CADIR/ca.conf" 2664 2729 2665 2730 _DEFAULT_ACCOUNT_KEY_PATH="$CA_DIR/account.key" … … 2667 2732 if [ -z "$ACCOUNT_KEY_PATH" ]; then 2668 2733 ACCOUNT_KEY_PATH="$_DEFAULT_ACCOUNT_KEY_PATH" 2734 if [ -f "$_OLD_ACCOUNT_KEY" ] && ! [ -f "$ACCOUNT_KEY_PATH" ]; then 2735 mkdir -p "$CA_DIR" 2736 mv "$_OLD_ACCOUNT_KEY" "$ACCOUNT_KEY_PATH" 2737 fi 2669 2738 fi 2670 2739 2671 2740 if [ -z "$ACCOUNT_JSON_PATH" ]; then 2672 2741 ACCOUNT_JSON_PATH="$_DEFAULT_ACCOUNT_JSON_PATH" 2742 if [ -f "$_OLD_ACCOUNT_JSON" ] && ! [ -f "$ACCOUNT_JSON_PATH" ]; then 2743 mkdir -p "$CA_DIR" 2744 mv "$_OLD_ACCOUNT_JSON" "$ACCOUNT_JSON_PATH" 2745 fi 2746 fi 2747 2748 if [ -f "$_OLD_CA_CONF" ] && ! [ -f "$CA_CONF" ]; then 2749 mkdir -p "$CA_DIR" 2750 mv "$_OLD_CA_CONF" "$CA_CONF" 2751 fi 2752 2753 if [ -f "$CA_CONF" ]; then 2754 . "$CA_CONF" 2755 fi 2756 2757 if [ -z "$ACME_DIR" ]; then 2758 ACME_DIR="/home/.acme" 2759 fi 2760 2761 if [ -z "$APACHE_CONF_BACKUP_DIR" ]; then 2762 APACHE_CONF_BACKUP_DIR="$LE_CONFIG_HOME" 2763 fi 2764 2765 if [ -z "$USER_AGENT" ]; then 2766 USER_AGENT="$DEFAULT_USER_AGENT" 2767 fi 2768 2769 if [ -z "$HTTP_HEADER" ]; then 2770 HTTP_HEADER="$LE_CONFIG_HOME/http.header" 2673 2771 fi 2674 2772 … … 3070 3168 for included in $(cat "$2" | tr "\t" " " | grep "^ *include *.*;" | sed "s/include //" | tr -d " ;"); do 3071 3169 _debug "check included $included" 3170 if ! _startswith "$included" "/" && _exists dirname; then 3171 _relpath="$(dirname "$_c_file")" 3172 _debug "_relpath" "$_relpath" 3173 included="$_relpath/$included" 3174 fi 3072 3175 if _checkConf "$1" "$included"; then 3073 3176 return 0 … … 3280 3383 _info "Run pre hook:'$_chk_pre_hook'" 3281 3384 if ! ( 3385 export Le_Domain="$_chk_main_domain" 3386 export Le_Alt="$_chk_alt_domains" 3282 3387 cd "$DOMAIN_PATH" && eval "$_chk_pre_hook" 3283 3388 ); then … … 3341 3446 netprc="$(echo "$_netprc" | grep "$_checkaddr")" 3342 3447 if [ -z "$netprc" ]; then 3343 netprc="$(echo "$_netprc" | grep "$LOCAL_ANY_ADDRESS ")"3448 netprc="$(echo "$_netprc" | grep "$LOCAL_ANY_ADDRESS:$_checkport")" 3344 3449 fi 3345 3450 if [ "$netprc" ]; then … … 3498 3603 3499 3604 mkdir -p "$CA_DIR" 3500 if [ ! -f "$ACCOUNT_KEY_PATH" ] && [ -f "$_OLD_ACCOUNT_KEY" ]; then3501 _info "mv $_OLD_ACCOUNT_KEY to $ACCOUNT_KEY_PATH"3502 mv "$_OLD_ACCOUNT_KEY" "$ACCOUNT_KEY_PATH"3503 fi3504 3505 if [ ! -f "$ACCOUNT_JSON_PATH" ] && [ -f "$_OLD_ACCOUNT_JSON" ]; then3506 _info "mv $_OLD_ACCOUNT_JSON to $ACCOUNT_JSON_PATH"3507 mv "$_OLD_ACCOUNT_JSON" "$ACCOUNT_JSON_PATH"3508 fi3509 3605 3510 3606 if [ ! -f "$ACCOUNT_KEY_PATH" ]; then … … 3530 3626 _savecaconf "CA_EMAIL" "$_email" 3531 3627 fi 3532 if [ "$ACME_VERSION" = "2" ]; then 3533 if [ "$ACME_DIRECTORY" = "$CA_ZEROSSL" ]; then 3534 if [ -z "$_eab_id" ] || [ -z "$_eab_hmac_key" ]; then 3535 _info "No EAB credentials found for ZeroSSL, let's get one" 3536 if [ -z "$_email" ]; then 3537 _err "Please provide a email address for ZeroSSL account." 3538 _err "See ZeroSSL usage: $_ZEROSSL_WIKI" 3539 return 1 3540 fi 3541 _eabresp=$(_post "email=$_email" $_ZERO_EAB_ENDPOINT) 3542 if [ "$?" != "0" ]; then 3543 _debug2 "$_eabresp" 3544 _err "Can not get EAB credentials from ZeroSSL." 3545 return 1 3546 fi 3547 _eab_id="$(echo "$_eabresp" | tr ',}' '\n' | grep '"eab_kid"' | cut -d : -f 2 | tr -d '"')" 3548 if [ -z "$_eab_id" ]; then 3549 _err "Can not resolve _eab_id" 3550 return 1 3551 fi 3552 _eab_hmac_key="$(echo "$_eabresp" | tr ',}' '\n' | grep '"eab_hmac_key"' | cut -d : -f 2 | tr -d '"')" 3553 if [ -z "$_eab_hmac_key" ]; then 3554 _err "Can not resolve _eab_hmac_key" 3555 return 1 3556 fi 3557 _savecaconf CA_EAB_KEY_ID "$_eab_id" 3558 _savecaconf CA_EAB_HMAC_KEY "$_eab_hmac_key" 3559 fi 3560 fi 3561 if [ "$_eab_id" ] && [ "$_eab_hmac_key" ]; then 3562 eab_protected="{\"alg\":\"HS256\",\"kid\":\"$_eab_id\",\"url\":\"${ACME_NEW_ACCOUNT}\"}" 3563 _debug3 eab_protected "$eab_protected" 3564 3565 eab_protected64=$(printf "%s" "$eab_protected" | _base64 | _url_replace) 3566 _debug3 eab_protected64 "$eab_protected64" 3567 3568 eab_payload64=$(printf "%s" "$jwk" | _base64 | _url_replace) 3569 _debug3 eab_payload64 "$eab_payload64" 3570 3571 eab_sign_t="$eab_protected64.$eab_payload64" 3572 _debug3 eab_sign_t "$eab_sign_t" 3573 3574 key_hex="$(_durl_replace_base64 "$_eab_hmac_key" | _dbase64 | _hex_dump | tr -d ' ')" 3575 _debug3 key_hex "$key_hex" 3576 3577 eab_signature=$(printf "%s" "$eab_sign_t" | _hmac sha256 $key_hex | _base64 | _url_replace) 3578 _debug3 eab_signature "$eab_signature" 3579 3580 externalBinding=",\"externalAccountBinding\":{\"protected\":\"$eab_protected64\", \"payload\":\"$eab_payload64\", \"signature\":\"$eab_signature\"}" 3581 _debug3 externalBinding "$externalBinding" 3582 fi 3583 if [ "$_email" ]; then 3584 email_sg="\"contact\": [\"mailto:$_email\"], " 3585 fi 3586 regjson="{$email_sg\"termsOfServiceAgreed\": true$externalBinding}" 3587 else 3588 _reg_res="$ACME_NEW_ACCOUNT_RES" 3589 regjson='{"resource": "'$_reg_res'", "terms-of-service-agreed": true, "agreement": "'$ACME_AGREEMENT'"}' 3590 if [ "$_email" ]; then 3591 regjson='{"resource": "'$_reg_res'", "contact": ["mailto:'$_email'"], "terms-of-service-agreed": true, "agreement": "'$ACME_AGREEMENT'"}' 3592 fi 3593 fi 3628 3629 if [ "$ACME_DIRECTORY" = "$CA_ZEROSSL" ]; then 3630 if [ -z "$_eab_id" ] || [ -z "$_eab_hmac_key" ]; then 3631 _info "No EAB credentials found for ZeroSSL, let's get one" 3632 if [ -z "$_email" ]; then 3633 _info "$(__green "$PROJECT_NAME is using ZeroSSL as default CA now.")" 3634 _info "$(__green "Please update your account with an email address first.")" 3635 _info "$(__green "$PROJECT_ENTRY --register-account -m my@example.com")" 3636 _info "See: $(__green "$_ZEROSSL_WIKI")" 3637 return 1 3638 fi 3639 _eabresp=$(_post "email=$_email" $_ZERO_EAB_ENDPOINT) 3640 if [ "$?" != "0" ]; then 3641 _debug2 "$_eabresp" 3642 _err "Can not get EAB credentials from ZeroSSL." 3643 return 1 3644 fi 3645 _secure_debug2 _eabresp "$_eabresp" 3646 _eab_id="$(echo "$_eabresp" | tr ',}' '\n\n' | grep '"eab_kid"' | cut -d : -f 2 | tr -d '"')" 3647 _secure_debug2 _eab_id "$_eab_id" 3648 if [ -z "$_eab_id" ]; then 3649 _err "Can not resolve _eab_id" 3650 return 1 3651 fi 3652 _eab_hmac_key="$(echo "$_eabresp" | tr ',}' '\n\n' | grep '"eab_hmac_key"' | cut -d : -f 2 | tr -d '"')" 3653 _secure_debug2 _eab_hmac_key "$_eab_hmac_key" 3654 if [ -z "$_eab_hmac_key" ]; then 3655 _err "Can not resolve _eab_hmac_key" 3656 return 1 3657 fi 3658 _savecaconf CA_EAB_KEY_ID "$_eab_id" 3659 _savecaconf CA_EAB_HMAC_KEY "$_eab_hmac_key" 3660 fi 3661 fi 3662 if [ "$_eab_id" ] && [ "$_eab_hmac_key" ]; then 3663 eab_protected="{\"alg\":\"HS256\",\"kid\":\"$_eab_id\",\"url\":\"${ACME_NEW_ACCOUNT}\"}" 3664 _debug3 eab_protected "$eab_protected" 3665 3666 eab_protected64=$(printf "%s" "$eab_protected" | _base64 | _url_replace) 3667 _debug3 eab_protected64 "$eab_protected64" 3668 3669 eab_payload64=$(printf "%s" "$jwk" | _base64 | _url_replace) 3670 _debug3 eab_payload64 "$eab_payload64" 3671 3672 eab_sign_t="$eab_protected64.$eab_payload64" 3673 _debug3 eab_sign_t "$eab_sign_t" 3674 3675 key_hex="$(_durl_replace_base64 "$_eab_hmac_key" | _dbase64 multi | _hex_dump | tr -d ' ')" 3676 _debug3 key_hex "$key_hex" 3677 3678 eab_signature=$(printf "%s" "$eab_sign_t" | _hmac sha256 $key_hex | _base64 | _url_replace) 3679 _debug3 eab_signature "$eab_signature" 3680 3681 externalBinding=",\"externalAccountBinding\":{\"protected\":\"$eab_protected64\", \"payload\":\"$eab_payload64\", \"signature\":\"$eab_signature\"}" 3682 _debug3 externalBinding "$externalBinding" 3683 fi 3684 if [ "$_email" ]; then 3685 email_sg="\"contact\": [\"mailto:$_email\"], " 3686 fi 3687 regjson="{$email_sg\"termsOfServiceAgreed\": true$externalBinding}" 3594 3688 3595 3689 _info "Registering account: $ACME_DIRECTORY" … … 3646 3740 _initpath 3647 3741 3648 if [ ! -f "$ACCOUNT_KEY_PATH" ] && [ -f "$_OLD_ACCOUNT_KEY" ]; then3649 _info "mv $_OLD_ACCOUNT_KEY to $ACCOUNT_KEY_PATH"3650 mv "$_OLD_ACCOUNT_KEY" "$ACCOUNT_KEY_PATH"3651 fi3652 3653 if [ ! -f "$ACCOUNT_JSON_PATH" ] && [ -f "$_OLD_ACCOUNT_JSON" ]; then3654 _info "mv $_OLD_ACCOUNT_JSON to $ACCOUNT_JSON_PATH"3655 mv "$_OLD_ACCOUNT_JSON" "$ACCOUNT_JSON_PATH"3656 fi3657 3658 3742 if [ ! -f "$ACCOUNT_KEY_PATH" ]; then 3659 3743 _err "Account key is not found at: $ACCOUNT_KEY_PATH" … … 3676 3760 3677 3761 _email="$(_getAccountEmail)" 3678 if [ "$ACME_VERSION" = "2" ]; then 3679 if [ "$ACCOUNT_EMAIL" ]; then 3680 updjson='{"contact": ["mailto:'$_email'"]}' 3681 else 3682 updjson='{"contact": []}' 3683 fi 3762 3763 if [ "$ACCOUNT_EMAIL" ]; then 3764 updjson='{"contact": ["mailto:'$_email'"]}' 3684 3765 else 3685 # ACMEv1: Updates happen the same way a registration is done. 3686 # https://tools.ietf.org/html/draft-ietf-acme-acme-01#section-6.3 3687 _regAccount 3688 return 3689 fi 3690 3691 # this part handles ACMEv2 account updates. 3766 updjson='{"contact": []}' 3767 fi 3768 3692 3769 _send_signed_request "$_accUri" "$updjson" 3693 3770 … … 3705 3782 _initpath 3706 3783 3707 if [ ! -f "$ACCOUNT_KEY_PATH" ] && [ -f "$_OLD_ACCOUNT_KEY" ]; then3708 _info "mv $_OLD_ACCOUNT_KEY to $ACCOUNT_KEY_PATH"3709 mv "$_OLD_ACCOUNT_KEY" "$ACCOUNT_KEY_PATH"3710 fi3711 3712 if [ ! -f "$ACCOUNT_JSON_PATH" ] && [ -f "$_OLD_ACCOUNT_JSON" ]; then3713 _info "mv $_OLD_ACCOUNT_JSON to $ACCOUNT_JSON_PATH"3714 mv "$_OLD_ACCOUNT_JSON" "$ACCOUNT_JSON_PATH"3715 fi3716 3717 3784 if [ ! -f "$ACCOUNT_KEY_PATH" ]; then 3718 3785 _err "Account key is not found at: $ACCOUNT_KEY_PATH" … … 3734 3801 _initAPI 3735 3802 3736 if [ "$ACME_VERSION" = "2" ]; then 3737 _djson="{\"status\":\"deactivated\"}" 3738 else 3739 _djson="{\"resource\": \"reg\", \"status\":\"deactivated\"}" 3740 fi 3803 _djson="{\"status\":\"deactivated\"}" 3804 3741 3805 if _send_signed_request "$_accUri" "$_djson" && _contains "$response" '"deactivated"'; then 3742 3806 _info "Deactivate account success for $_accUri." … … 3843 3907 _t_vtype="$3" 3844 3908 _debug2 _t_vtype "$_t_vtype" 3845 if [ "$ACME_VERSION" = "2" ]; then 3846 _send_signed_request "$_t_url" "{}" 3847 else 3848 _send_signed_request "$_t_url" "{\"resource\": \"challenge\", \"type\": \"$_t_vtype\", \"keyAuthorization\": \"$_t_key_authz\"}" 3849 fi 3909 3910 _send_signed_request "$_t_url" "{}" 3911 3850 3912 } 3851 3913 … … 3890 3952 #checks if cf server is available 3891 3953 _ns_is_available_cf() { 3892 if _get "https://cloudflare-dns.com" >/dev/null 2>&1; then 3954 if _get "https://cloudflare-dns.com" "" 1 >/dev/null 2>&1; then 3955 return 0 3956 else 3957 return 1 3958 fi 3959 } 3960 3961 _ns_is_available_google() { 3962 if _get "https://dns.google" "" 1 >/dev/null 2>&1; then 3893 3963 return 0 3894 3964 else … … 3902 3972 _cf_ld_type="$2" 3903 3973 _cf_ep="https://dns.google/resolve" 3974 _ns_lookup_impl "$_cf_ep" "$_cf_ld" "$_cf_ld_type" 3975 } 3976 3977 _ns_is_available_ali() { 3978 if _get "https://dns.alidns.com" "" 1 >/dev/null 2>&1; then 3979 return 0 3980 else 3981 return 1 3982 fi 3983 } 3984 3985 #domain, type 3986 _ns_lookup_ali() { 3987 _cf_ld="$1" 3988 _cf_ld_type="$2" 3989 _cf_ep="https://dns.alidns.com/resolve" 3990 _ns_lookup_impl "$_cf_ep" "$_cf_ld" "$_cf_ld_type" 3991 } 3992 3993 _ns_is_available_dp() { 3994 if _get "https://doh.pub" "" 1 >/dev/null 2>&1; then 3995 return 0 3996 else 3997 return 1 3998 fi 3999 } 4000 4001 #dnspod 4002 _ns_lookup_dp() { 4003 _cf_ld="$1" 4004 _cf_ld_type="$2" 4005 _cf_ep="https://doh.pub/dns-query" 3904 4006 _ns_lookup_impl "$_cf_ep" "$_cf_ld" "$_cf_ld_type" 3905 4007 } … … 3912 4014 _debug "Use cloudflare doh server" 3913 4015 export DOH_USE=$DOH_CLOUDFLARE 3914 el se4016 elif _ns_is_available_google; then 3915 4017 _debug "Use google doh server" 3916 4018 export DOH_USE=$DOH_GOOGLE 4019 elif _ns_is_available_ali; then 4020 _debug "Use aliyun doh server" 4021 export DOH_USE=$DOH_ALI 4022 elif _ns_is_available_dp; then 4023 _debug "Use dns pod doh server" 4024 export DOH_USE=$DOH_DP 4025 else 4026 _err "No doh" 3917 4027 fi 3918 4028 fi … … 3920 4030 if [ "$DOH_USE" = "$DOH_CLOUDFLARE" ] || [ -z "$DOH_USE" ]; then 3921 4031 _ns_lookup_cf "$@" 4032 elif [ "$DOH_USE" = "$DOH_GOOGLE" ]; then 4033 _ns_lookup_google "$@" 4034 elif [ "$DOH_USE" = "$DOH_ALI" ]; then 4035 _ns_lookup_ali "$@" 4036 elif [ "$DOH_USE" = "$DOH_DP" ]; then 4037 _ns_lookup_dp "$@" 3922 4038 else 3923 _ ns_lookup_google "$@"4039 _err "Unknown doh provider: DOH_USE=$DOH_USE" 3924 4040 fi 3925 4041 … … 3946 4062 _ns_purge_cf "$_p_txtdomain" "TXT" 3947 4063 else 3948 _debug "no purge api for google dnsapi, just sleep 5 secs"4064 _debug "no purge api for this doh api, just sleep 5 secs" 3949 4065 _sleep 5 3950 4066 fi … … 3959 4075 3960 4076 while [ "$(_time)" -le "$_end_time" ]; do 4077 _info "You can use '--dnssleep' to disable public dns checks." 4078 _info "See: $_DNSCHECK_WIKI" 3961 4079 _left="" 3962 4080 for entry in $dns_entries; do … … 4006 4124 4007 4125 #file 4008 _get_c ert_issuers() {4126 _get_chain_issuers() { 4009 4127 _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"; then4011 ${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 24128 if _contains "$(${ACME_OPENSSL_BIN:-openssl} help crl2pkcs7 2>&1)" "Usage: crl2pkcs7" || _contains "$(${ACME_OPENSSL_BIN:-openssl} crl2pkcs7 -help 2>&1)" "Usage: crl2pkcs7" || _contains "$(${ACME_OPENSSL_BIN:-openssl} crl2pkcs7 help 2>&1)" "unknown option help"; then 4129 ${ACME_OPENSSL_BIN:-openssl} crl2pkcs7 -nocrl -certfile $_cfile | ${ACME_OPENSSL_BIN:-openssl} pkcs7 -print_certs -text -noout | grep -i 'Issuer:' | _egrep_o "CN *=[^,]*" | cut -d = -f 2 4012 4130 else 4013 ${ACME_OPENSSL_BIN:-openssl} x509 -in $_cfile -text -noout | grep 'Issuer:' | _egrep_o "CN *=[^,]*" | cut -d = -f 2 4131 _cindex=1 4132 for _startn in $(grep -n -- "$BEGIN_CERT" "$_cfile" | cut -d : -f 1); do 4133 _endn="$(grep -n -- "$END_CERT" "$_cfile" | cut -d : -f 1 | _head_n $_cindex | _tail_n 1)" 4134 _debug2 "_startn" "$_startn" 4135 _debug2 "_endn" "$_endn" 4136 if [ "$DEBUG" ]; then 4137 _debug2 "cert$_cindex" "$(sed -n "$_startn,${_endn}p" "$_cfile")" 4138 fi 4139 sed -n "$_startn,${_endn}p" "$_cfile" | ${ACME_OPENSSL_BIN:-openssl} x509 -text -noout | grep 'Issuer:' | _egrep_o "CN *=[^,]*" | cut -d = -f 2 | sed "s/ *\(.*\)/\1/" 4140 _cindex=$(_math $_cindex + 1) 4141 done 4142 fi 4143 } 4144 4145 # 4146 _get_chain_subjects() { 4147 _cfile="$1" 4148 if _contains "$(${ACME_OPENSSL_BIN:-openssl} help crl2pkcs7 2>&1)" "Usage: crl2pkcs7" || _contains "$(${ACME_OPENSSL_BIN:-openssl} crl2pkcs7 -help 2>&1)" "Usage: crl2pkcs7" || _contains "$(${ACME_OPENSSL_BIN:-openssl} crl2pkcs7 help 2>&1)" "unknown option help"; then 4149 ${ACME_OPENSSL_BIN:-openssl} crl2pkcs7 -nocrl -certfile $_cfile | ${ACME_OPENSSL_BIN:-openssl} pkcs7 -print_certs -text -noout | grep -i 'Subject:' | _egrep_o "CN *=[^,]*" | cut -d = -f 2 4150 else 4151 _cindex=1 4152 for _startn in $(grep -n -- "$BEGIN_CERT" "$_cfile" | cut -d : -f 1); do 4153 _endn="$(grep -n -- "$END_CERT" "$_cfile" | cut -d : -f 1 | _head_n $_cindex | _tail_n 1)" 4154 _debug2 "_startn" "$_startn" 4155 _debug2 "_endn" "$_endn" 4156 if [ "$DEBUG" ]; then 4157 _debug2 "cert$_cindex" "$(sed -n "$_startn,${_endn}p" "$_cfile")" 4158 fi 4159 sed -n "$_startn,${_endn}p" "$_cfile" | ${ACME_OPENSSL_BIN:-openssl} x509 -text -noout | grep -i 'Subject:' | _egrep_o "CN *=[^,]*" | cut -d = -f 2 | sed "s/ *\(.*\)/\1/" 4160 _cindex=$(_math $_cindex + 1) 4161 done 4014 4162 fi 4015 4163 } … … 4019 4167 _cfile="$1" 4020 4168 _missuer="$2" 4021 _fissuers="$(_get_c ert_issuers $_cfile)"4169 _fissuers="$(_get_chain_issuers $_cfile)" 4022 4170 _debug2 _fissuers "$_fissuers" 4023 if _contains "$_fissuers" "$_missuer"; then 4024 return 0 4025 fi 4026 _fissuers="$(echo "$_fissuers" | _lower_case)" 4171 _rootissuer="$(echo "$_fissuers" | _lower_case | _tail_n 1)" 4172 _debug2 _rootissuer "$_rootissuer" 4027 4173 _missuer="$(echo "$_missuer" | _lower_case)" 4028 _contains "$_ fissuers" "$_missuer"4174 _contains "$_rootissuer" "$_missuer" 4029 4175 } 4030 4176 … … 4066 4212 _initpath "$_main_domain" "$_key_length" 4067 4213 mkdir -p "$DOMAIN_PATH" 4214 elif ! _hasfield "$_web_roots" "$W_DNS"; then 4215 Le_OrderFinalize="" 4216 Le_LinkOrder="" 4217 Le_LinkCert="" 4068 4218 fi 4069 4219 … … 4075 4225 _debug "Using ACME_DIRECTORY: $ACME_DIRECTORY" 4076 4226 4077 _initAPI 4227 if ! _initAPI; then 4228 return 1 4229 fi 4078 4230 4079 4231 if [ -f "$DOMAIN_CONF" ]; then … … 4179 4331 dvsep=',' 4180 4332 if [ -z "$vlist" ]; then 4181 if [ "$ACME_VERSION" = "2" ]; then 4182 #make new order request 4183 _identifiers="{\"type\":\"dns\",\"value\":\"$(_idn "$_main_domain")\"}" 4184 _w_index=1 4185 while true; do 4186 d="$(echo "$_alt_domains," | cut -d , -f "$_w_index")" 4187 _w_index="$(_math "$_w_index" + 1)" 4188 _debug d "$d" 4189 if [ -z "$d" ]; then 4190 break 4191 fi 4192 _identifiers="$_identifiers,{\"type\":\"dns\",\"value\":\"$(_idn "$d")\"}" 4193 done 4194 _debug2 _identifiers "$_identifiers" 4195 if ! _send_signed_request "$ACME_NEW_ORDER" "{\"identifiers\": [$_identifiers]}"; then 4196 _err "Create new order error." 4333 #make new order request 4334 _identifiers="{\"type\":\"dns\",\"value\":\"$(_idn "$_main_domain")\"}" 4335 _w_index=1 4336 while true; do 4337 d="$(echo "$_alt_domains," | cut -d , -f "$_w_index")" 4338 _w_index="$(_math "$_w_index" + 1)" 4339 _debug d "$d" 4340 if [ -z "$d" ]; then 4341 break 4342 fi 4343 _identifiers="$_identifiers,{\"type\":\"dns\",\"value\":\"$(_idn "$d")\"}" 4344 done 4345 _debug2 _identifiers "$_identifiers" 4346 if ! _send_signed_request "$ACME_NEW_ORDER" "{\"identifiers\": [$_identifiers]}"; then 4347 _err "Create new order error." 4348 _clearup 4349 _on_issue_err "$_post_hook" 4350 return 1 4351 fi 4352 Le_LinkOrder="$(echo "$responseHeaders" | grep -i '^Location.*$' | _tail_n 1 | tr -d "\r\n " | cut -d ":" -f 2-)" 4353 _debug Le_LinkOrder "$Le_LinkOrder" 4354 Le_OrderFinalize="$(echo "$response" | _egrep_o '"finalize" *: *"[^"]*"' | cut -d '"' -f 4)" 4355 _debug Le_OrderFinalize "$Le_OrderFinalize" 4356 if [ -z "$Le_OrderFinalize" ]; then 4357 _err "Create new order error. Le_OrderFinalize not found. $response" 4358 _clearup 4359 _on_issue_err "$_post_hook" 4360 return 1 4361 fi 4362 4363 #for dns manual mode 4364 _savedomainconf "Le_OrderFinalize" "$Le_OrderFinalize" 4365 4366 _authorizations_seg="$(echo "$response" | _json_decode | _egrep_o '"authorizations" *: *\[[^\[]*\]' | cut -d '[' -f 2 | tr -d ']' | tr -d '"')" 4367 _debug2 _authorizations_seg "$_authorizations_seg" 4368 if [ -z "$_authorizations_seg" ]; then 4369 _err "_authorizations_seg not found." 4370 _clearup 4371 _on_issue_err "$_post_hook" 4372 return 1 4373 fi 4374 4375 #domain and authz map 4376 _authorizations_map="" 4377 for _authz_url in $(echo "$_authorizations_seg" | tr ',' ' '); do 4378 _debug2 "_authz_url" "$_authz_url" 4379 if ! _send_signed_request "$_authz_url"; then 4380 _err "get to authz error." 4381 _err "_authorizations_seg" "$_authorizations_seg" 4382 _err "_authz_url" "$_authz_url" 4197 4383 _clearup 4198 4384 _on_issue_err "$_post_hook" 4199 4385 return 1 4200 4386 fi 4201 Le_LinkOrder="$(echo "$responseHeaders" | grep -i '^Location.*$' | _tail_n 1 | tr -d "\r\n " | cut -d ":" -f 2-)" 4202 _debug Le_LinkOrder "$Le_LinkOrder" 4203 Le_OrderFinalize="$(echo "$response" | _egrep_o '"finalize" *: *"[^"]*"' | cut -d '"' -f 4)" 4204 _debug Le_OrderFinalize "$Le_OrderFinalize" 4205 if [ -z "$Le_OrderFinalize" ]; then 4206 _err "Create new order error. Le_OrderFinalize not found. $response" 4207 _clearup 4208 _on_issue_err "$_post_hook" 4209 return 1 4210 fi 4211 4212 #for dns manual mode 4213 _savedomainconf "Le_OrderFinalize" "$Le_OrderFinalize" 4214 4215 _authorizations_seg="$(echo "$response" | _json_decode | _egrep_o '"authorizations" *: *\[[^\[]*\]' | cut -d '[' -f 2 | tr -d ']' | tr -d '"')" 4216 _debug2 _authorizations_seg "$_authorizations_seg" 4217 if [ -z "$_authorizations_seg" ]; then 4218 _err "_authorizations_seg not found." 4219 _clearup 4220 _on_issue_err "$_post_hook" 4221 return 1 4222 fi 4223 4224 #domain and authz map 4225 _authorizations_map="" 4226 for _authz_url in $(echo "$_authorizations_seg" | tr ',' ' '); do 4227 _debug2 "_authz_url" "$_authz_url" 4228 if ! _send_signed_request "$_authz_url"; then 4229 _err "get to authz error." 4230 _err "_authorizations_seg" "$_authorizations_seg" 4231 _err "_authz_url" "$_authz_url" 4232 _clearup 4233 _on_issue_err "$_post_hook" 4234 return 1 4235 fi 4236 4237 response="$(echo "$response" | _normalizeJson)" 4238 _debug2 response "$response" 4239 _d="$(echo "$response" | _egrep_o '"value" *: *"[^"]*"' | cut -d : -f 2 | tr -d ' "')" 4240 if _contains "$response" "\"wildcard\" *: *true"; then 4241 _d="*.$_d" 4242 fi 4243 _debug2 _d "$_d" 4244 _authorizations_map="$_d,$response 4387 4388 response="$(echo "$response" | _normalizeJson)" 4389 _debug2 response "$response" 4390 _d="$(echo "$response" | _egrep_o '"value" *: *"[^"]*"' | cut -d : -f 2 | tr -d ' "')" 4391 if _contains "$response" "\"wildcard\" *: *true"; then 4392 _d="*.$_d" 4393 fi 4394 _debug2 _d "$_d" 4395 _authorizations_map="$_d,$response 4245 4396 $_authorizations_map" 4246 done 4247 _debug2 _authorizations_map "$_authorizations_map" 4248 fi 4397 done 4398 _debug2 _authorizations_map "$_authorizations_map" 4249 4399 4250 4400 _index=0 … … 4277 4427 fi 4278 4428 4279 if [ "$ACME_VERSION" = "2" ]; then 4280 _idn_d="$(_idn "$d")" 4281 _candidates="$(echo "$_authorizations_map" | grep -i "^$_idn_d,")" 4282 _debug2 _candidates "$_candidates" 4283 if [ "$(echo "$_candidates" | wc -l)" -gt 1 ]; then 4284 for _can in $_candidates; do 4285 if _startswith "$(echo "$_can" | tr '.' '|')" "$(echo "$_idn_d" | tr '.' '|'),"; then 4286 _candidates="$_can" 4287 break 4288 fi 4289 done 4290 fi 4291 response="$(echo "$_candidates" | sed "s/$_idn_d,//")" 4292 _debug2 "response" "$response" 4293 if [ -z "$response" ]; then 4294 _err "get to authz error." 4295 _err "_authorizations_map" "$_authorizations_map" 4296 _clearup 4297 _on_issue_err "$_post_hook" 4298 return 1 4299 fi 4300 else 4301 if ! __get_domain_new_authz "$d"; then 4302 _clearup 4303 _on_issue_err "$_post_hook" 4304 return 1 4305 fi 4429 _idn_d="$(_idn "$d")" 4430 _candidates="$(echo "$_authorizations_map" | grep -i "^$_idn_d,")" 4431 _debug2 _candidates "$_candidates" 4432 if [ "$(echo "$_candidates" | wc -l)" -gt 1 ]; then 4433 for _can in $_candidates; do 4434 if _startswith "$(echo "$_can" | tr '.' '|')" "$(echo "$_idn_d" | tr '.' '|'),"; then 4435 _candidates="$_can" 4436 break 4437 fi 4438 done 4439 fi 4440 response="$(echo "$_candidates" | sed "s/$_idn_d,//")" 4441 _debug2 "response" "$response" 4442 if [ -z "$response" ]; then 4443 _err "get to authz error." 4444 _err "_authorizations_map" "$_authorizations_map" 4445 _clearup 4446 _on_issue_err "$_post_hook" 4447 return 1 4306 4448 fi 4307 4449 … … 4344 4486 return 1 4345 4487 fi 4346 if [ "$ACME_VERSION" = "2" ]; then 4347 uri="$(echo "$entry" | _egrep_o '"url":"[^"]*' | cut -d '"' -f 4 | _head_n 1)" 4348 else 4349 uri="$(echo "$entry" | _egrep_o '"uri":"[^"]*' | cut -d '"' -f 4)" 4350 fi 4488 4489 uri="$(echo "$entry" | _egrep_o '"url":"[^"]*' | cut -d '"' -f 4 | _head_n 1)" 4490 4351 4491 _debug uri "$uri" 4352 4492 … … 4643 4783 fi 4644 4784 4645 _debug "sleep 2 secs to verify"4646 sleep 24647 _debug "checking"4648 if [ "$ACME_VERSION" = "2" ]; then4649 _send_signed_request "$uri"4650 else4651 response="$(_get "$uri")"4652 fi4653 if [ "$?" != "0" ]; then4654 _err "$d:Verify error:$response"4655 _clearupwebbroot "$_currentRoot" "$removelevel" "$token"4656 _clearup4657 _on_issue_err "$_post_hook" "$vlist"4658 return 14659 fi4660 4785 _debug2 original "$response" 4661 4786 … … 4664 4789 4665 4790 status=$(echo "$response" | _egrep_o '"status":"[^"]*' | cut -d : -f 2 | tr -d '"') 4666 if [ "$status" = "valid" ]; then 4667 _info "$(__green Success)" 4668 _stopserver "$serverproc" 4669 serverproc="" 4670 _clearupwebbroot "$_currentRoot" "$removelevel" "$token" 4671 break 4672 fi 4673 4674 if [ "$status" = "invalid" ]; then 4791 _debug2 status "$status" 4792 if _contains "$status" "invalid"; then 4675 4793 error="$(echo "$response" | _egrep_o '"error":\{[^\}]*')" 4676 4794 _debug2 error "$error" … … 4694 4812 fi 4695 4813 4814 if _contains "$status" "valid"; then 4815 _info "$(__green Success)" 4816 _stopserver "$serverproc" 4817 serverproc="" 4818 _clearupwebbroot "$_currentRoot" "$removelevel" "$token" 4819 break 4820 fi 4821 4696 4822 if [ "$status" = "pending" ]; then 4697 _info "Pending "4823 _info "Pending, The CA is processing your order, please just wait. ($waittimes/$MAX_RETRY_TIMES)" 4698 4824 elif [ "$status" = "processing" ]; then 4699 _info "Processing "4825 _info "Processing, The CA is processing your order, please just wait. ($waittimes/$MAX_RETRY_TIMES)" 4700 4826 else 4701 4827 _err "$d:Verify error:$response" … … 4705 4831 return 1 4706 4832 fi 4707 4833 _debug "sleep 2 secs to verify again" 4834 sleep 2 4835 _debug "checking" 4836 4837 _send_signed_request "$uri" 4838 4839 if [ "$?" != "0" ]; then 4840 _err "$d:Verify error:$response" 4841 _clearupwebbroot "$_currentRoot" "$removelevel" "$token" 4842 _clearup 4843 _on_issue_err "$_post_hook" "$vlist" 4844 return 1 4845 fi 4708 4846 done 4709 4847 … … 4714 4852 der="$(_getfile "${CSR_PATH}" "${BEGIN_CSR}" "${END_CSR}" | tr -d "\r\n" | _url_replace)" 4715 4853 4716 if [ "$ACME_VERSION" = "2" ]; then 4717 _info "Lets finalize the order." 4718 _info "Le_OrderFinalize" "$Le_OrderFinalize" 4719 if ! _send_signed_request "${Le_OrderFinalize}" "{\"csr\": \"$der\"}"; then 4720 _err "Sign failed." 4721 _on_issue_err "$_post_hook" 4722 return 1 4723 fi 4724 if [ "$code" != "200" ]; then 4725 _err "Sign failed, finalize code is not 200." 4854 _info "Lets finalize the order." 4855 _info "Le_OrderFinalize" "$Le_OrderFinalize" 4856 if ! _send_signed_request "${Le_OrderFinalize}" "{\"csr\": \"$der\"}"; then 4857 _err "Sign failed." 4858 _on_issue_err "$_post_hook" 4859 return 1 4860 fi 4861 if [ "$code" != "200" ]; then 4862 _err "Sign failed, finalize code is not 200." 4863 _err "$response" 4864 _on_issue_err "$_post_hook" 4865 return 1 4866 fi 4867 if [ -z "$Le_LinkOrder" ]; then 4868 Le_LinkOrder="$(echo "$responseHeaders" | grep -i '^Location.*$' | _tail_n 1 | tr -d "\r\n \t" | cut -d ":" -f 2-)" 4869 fi 4870 4871 _savedomainconf "Le_LinkOrder" "$Le_LinkOrder" 4872 4873 _link_cert_retry=0 4874 _MAX_CERT_RETRY=30 4875 while [ "$_link_cert_retry" -lt "$_MAX_CERT_RETRY" ]; do 4876 if _contains "$response" "\"status\":\"valid\""; then 4877 _debug "Order status is valid." 4878 Le_LinkCert="$(echo "$response" | _egrep_o '"certificate" *: *"[^"]*"' | cut -d '"' -f 4)" 4879 _debug Le_LinkCert "$Le_LinkCert" 4880 if [ -z "$Le_LinkCert" ]; then 4881 _err "Sign error, can not find Le_LinkCert" 4882 _err "$response" 4883 _on_issue_err "$_post_hook" 4884 return 1 4885 fi 4886 break 4887 elif _contains "$response" "\"processing\""; then 4888 _info "Order status is processing, lets sleep and retry." 4889 _retryafter=$(echo "$responseHeaders" | grep -i "^Retry-After *:" | cut -d : -f 2 | tr -d ' ' | tr -d '\r') 4890 _debug "_retryafter" "$_retryafter" 4891 if [ "$_retryafter" ]; then 4892 _info "Retry after: $_retryafter" 4893 _sleep $_retryafter 4894 else 4895 _sleep 2 4896 fi 4897 else 4898 _err "Sign error, wrong status" 4726 4899 _err "$response" 4727 4900 _on_issue_err "$_post_hook" 4728 4901 return 1 4729 4902 fi 4903 #the order is processing, so we are going to poll order status 4730 4904 if [ -z "$Le_LinkOrder" ]; then 4731 Le_LinkOrder="$(echo "$responseHeaders" | grep -i '^Location.*$' | _tail_n 1 | tr -d "\r\n \t" | cut -d ":" -f 2-)" 4732 fi 4733 4734 _savedomainconf "Le_LinkOrder" "$Le_LinkOrder" 4735 4736 _link_cert_retry=0 4737 _MAX_CERT_RETRY=30 4738 while [ "$_link_cert_retry" -lt "$_MAX_CERT_RETRY" ]; do 4739 if _contains "$response" "\"status\":\"valid\""; then 4740 _debug "Order status is valid." 4741 Le_LinkCert="$(echo "$response" | _egrep_o '"certificate" *: *"[^"]*"' | cut -d '"' -f 4)" 4742 _debug Le_LinkCert "$Le_LinkCert" 4743 if [ -z "$Le_LinkCert" ]; then 4744 _err "Sign error, can not find Le_LinkCert" 4745 _err "$response" 4746 _on_issue_err "$_post_hook" 4747 return 1 4748 fi 4749 break 4750 elif _contains "$response" "\"processing\""; then 4751 _info "Order status is processing, lets sleep and retry." 4752 _retryafter=$(echo "$responseHeaders" | grep -i "^Retry-After *:" | cut -d : -f 2 | tr -d ' ' | tr -d '\r') 4753 _debug "_retryafter" "$_retryafter" 4754 if [ "$_retryafter" ]; then 4755 _info "Retry after: $_retryafter" 4756 _sleep $_retryafter 4757 else 4758 _sleep 2 4759 fi 4760 else 4761 _err "Sign error, wrong status" 4762 _err "$response" 4763 _on_issue_err "$_post_hook" 4764 return 1 4765 fi 4766 #the order is processing, so we are going to poll order status 4767 if [ -z "$Le_LinkOrder" ]; then 4768 _err "Sign error, can not get order link location header" 4769 _err "responseHeaders" "$responseHeaders" 4770 _on_issue_err "$_post_hook" 4771 return 1 4772 fi 4773 _info "Polling order status: $Le_LinkOrder" 4774 if ! _send_signed_request "$Le_LinkOrder"; then 4775 _err "Sign failed, can not post to Le_LinkOrder cert:$Le_LinkOrder." 4776 _err "$response" 4777 _on_issue_err "$_post_hook" 4778 return 1 4779 fi 4780 _link_cert_retry="$(_math $_link_cert_retry + 1)" 4781 done 4782 4783 if [ -z "$Le_LinkCert" ]; then 4784 _err "Sign failed, can not get Le_LinkCert, retry time limit." 4905 _err "Sign error, can not get order link location header" 4906 _err "responseHeaders" "$responseHeaders" 4907 _on_issue_err "$_post_hook" 4908 return 1 4909 fi 4910 _info "Polling order status: $Le_LinkOrder" 4911 if ! _send_signed_request "$Le_LinkOrder"; then 4912 _err "Sign failed, can not post to Le_LinkOrder cert:$Le_LinkOrder." 4785 4913 _err "$response" 4786 4914 _on_issue_err "$_post_hook" 4787 4915 return 1 4788 4916 fi 4789 _info "Downloading cert." 4790 _info "Le_LinkCert" "$Le_LinkCert" 4791 if ! _send_signed_request "$Le_LinkCert"; then 4792 _err "Sign failed, can not download cert:$Le_LinkCert." 4793 _err "$response" 4794 _on_issue_err "$_post_hook" 4795 return 1 4796 fi 4797 4798 echo "$response" >"$CERT_PATH" 4799 _split_cert_chain "$CERT_PATH" "$CERT_FULLCHAIN_PATH" "$CA_CERT_PATH" 4800 4801 if [ "$_preferred_chain" ] && [ -f "$CERT_FULLCHAIN_PATH" ]; then 4802 if ! _match_issuer "$CERT_FULLCHAIN_PATH" "$_preferred_chain"; then 4803 rels="$(echo "$responseHeaders" | tr -d ' <>' | grep -i "^link:" | grep -i 'rel="alternate"' | cut -d : -f 2- | cut -d ';' -f 1)" 4804 _debug2 "rels" "$rels" 4805 for rel in $rels; do 4806 _info "Try rel: $rel" 4807 if ! _send_signed_request "$rel"; then 4808 _err "Sign failed, can not download cert:$rel" 4809 _err "$response" 4810 continue 4811 fi 4812 _relcert="$CERT_PATH.alt" 4813 _relfullchain="$CERT_FULLCHAIN_PATH.alt" 4814 _relca="$CA_CERT_PATH.alt" 4815 echo "$response" >"$_relcert" 4816 _split_cert_chain "$_relcert" "$_relfullchain" "$_relca" 4817 if _match_issuer "$_relfullchain" "$_preferred_chain"; then 4818 _info "Matched issuer in: $rel" 4819 cat $_relcert >"$CERT_PATH" 4820 cat $_relfullchain >"$CERT_FULLCHAIN_PATH" 4821 cat $_relca >"$CA_CERT_PATH" 4822 break 4823 fi 4824 done 4825 fi 4826 fi 4827 else 4828 if ! _send_signed_request "${ACME_NEW_ORDER}" "{\"resource\": \"$ACME_NEW_ORDER_RES\", \"csr\": \"$der\"}" "needbase64"; then 4829 _err "Sign failed. $response" 4830 _on_issue_err "$_post_hook" 4831 return 1 4832 fi 4833 _rcert="$response" 4834 Le_LinkCert="$(grep -i '^Location.*$' "$HTTP_HEADER" | _tail_n 1 | tr -d "\r\n" | cut -d " " -f 2)" 4835 echo "$BEGIN_CERT" >"$CERT_PATH" 4836 4837 #if ! _get "$Le_LinkCert" | _base64 "multiline" >> "$CERT_PATH" ; then 4838 # _debug "Get cert failed. Let's try last response." 4839 # printf -- "%s" "$_rcert" | _dbase64 "multiline" | _base64 "multiline" >> "$CERT_PATH" 4840 #fi 4841 4842 if ! printf -- "%s" "$_rcert" | _dbase64 "multiline" | _base64 "multiline" >>"$CERT_PATH"; then 4843 _debug "Try cert link." 4844 _get "$Le_LinkCert" | _base64 "multiline" >>"$CERT_PATH" 4845 fi 4846 4847 echo "$END_CERT" >>"$CERT_PATH" 4917 _link_cert_retry="$(_math $_link_cert_retry + 1)" 4918 done 4919 4920 if [ -z "$Le_LinkCert" ]; then 4921 _err "Sign failed, can not get Le_LinkCert, retry time limit." 4922 _err "$response" 4923 _on_issue_err "$_post_hook" 4924 return 1 4925 fi 4926 _info "Downloading cert." 4927 _info "Le_LinkCert" "$Le_LinkCert" 4928 if ! _send_signed_request "$Le_LinkCert"; then 4929 _err "Sign failed, can not download cert:$Le_LinkCert." 4930 _err "$response" 4931 _on_issue_err "$_post_hook" 4932 return 1 4933 fi 4934 4935 echo "$response" >"$CERT_PATH" 4936 _split_cert_chain "$CERT_PATH" "$CERT_FULLCHAIN_PATH" "$CA_CERT_PATH" 4937 if [ -z "$_preferred_chain" ]; then 4938 _preferred_chain=$(_readcaconf DEFAULT_PREFERRED_CHAIN) 4939 fi 4940 if [ "$_preferred_chain" ] && [ -f "$CERT_FULLCHAIN_PATH" ]; then 4941 if [ "$DEBUG" ]; then 4942 _debug "default chain issuers: " "$(_get_chain_issuers "$CERT_FULLCHAIN_PATH")" 4943 fi 4944 if ! _match_issuer "$CERT_FULLCHAIN_PATH" "$_preferred_chain"; then 4945 rels="$(echo "$responseHeaders" | tr -d ' <>' | grep -i "^link:" | grep -i 'rel="alternate"' | cut -d : -f 2- | cut -d ';' -f 1)" 4946 _debug2 "rels" "$rels" 4947 for rel in $rels; do 4948 _info "Try rel: $rel" 4949 if ! _send_signed_request "$rel"; then 4950 _err "Sign failed, can not download cert:$rel" 4951 _err "$response" 4952 continue 4953 fi 4954 _relcert="$CERT_PATH.alt" 4955 _relfullchain="$CERT_FULLCHAIN_PATH.alt" 4956 _relca="$CA_CERT_PATH.alt" 4957 echo "$response" >"$_relcert" 4958 _split_cert_chain "$_relcert" "$_relfullchain" "$_relca" 4959 if [ "$DEBUG" ]; then 4960 _debug "rel chain issuers: " "$(_get_chain_issuers "$_relfullchain")" 4961 fi 4962 if _match_issuer "$_relfullchain" "$_preferred_chain"; then 4963 _info "Matched issuer in: $rel" 4964 cat $_relcert >"$CERT_PATH" 4965 cat $_relfullchain >"$CERT_FULLCHAIN_PATH" 4966 cat $_relca >"$CA_CERT_PATH" 4967 rm -f "$_relcert" 4968 rm -f "$_relfullchain" 4969 rm -f "$_relca" 4970 break 4971 fi 4972 rm -f "$_relcert" 4973 rm -f "$_relfullchain" 4974 rm -f "$_relca" 4975 done 4976 fi 4848 4977 fi 4849 4978 … … 4862 4991 cat "$CERT_PATH" 4863 4992 4864 _info "Your cert is in $(__green " $CERT_PATH")"4993 _info "Your cert is in: $(__green "$CERT_PATH")" 4865 4994 4866 4995 if [ -f "$CERT_KEY_PATH" ]; then 4867 _info "Your cert key is in $(__green " $CERT_KEY_PATH")"4996 _info "Your cert key is in: $(__green "$CERT_KEY_PATH")" 4868 4997 fi 4869 4998 … … 4874 5003 fi 4875 5004 4876 if [ "$ACME_VERSION" = "2" ]; then 4877 _debug "v2 chain." 4878 else 4879 cp "$CERT_PATH" "$CERT_FULLCHAIN_PATH" 4880 Le_LinkIssuer=$(grep -i '^Link' "$HTTP_HEADER" | _head_n 1 | cut -d " " -f 2 | cut -d ';' -f 1 | tr -d '<>') 4881 4882 if [ "$Le_LinkIssuer" ]; then 4883 if ! _contains "$Le_LinkIssuer" ":"; then 4884 _info "$(__red "Relative issuer link found.")" 4885 Le_LinkIssuer="$_ACME_SERVER_HOST$Le_LinkIssuer" 4886 fi 4887 _debug Le_LinkIssuer "$Le_LinkIssuer" 4888 _savedomainconf "Le_LinkIssuer" "$Le_LinkIssuer" 4889 4890 _link_issuer_retry=0 4891 _MAX_ISSUER_RETRY=5 4892 while [ "$_link_issuer_retry" -lt "$_MAX_ISSUER_RETRY" ]; do 4893 _debug _link_issuer_retry "$_link_issuer_retry" 4894 if [ "$ACME_VERSION" = "2" ]; then 4895 if _send_signed_request "$Le_LinkIssuer"; then 4896 echo "$response" >"$CA_CERT_PATH" 4897 break 4898 fi 4899 else 4900 if _get "$Le_LinkIssuer" >"$CA_CERT_PATH.der"; then 4901 echo "$BEGIN_CERT" >"$CA_CERT_PATH" 4902 _base64 "multiline" <"$CA_CERT_PATH.der" >>"$CA_CERT_PATH" 4903 echo "$END_CERT" >>"$CA_CERT_PATH" 4904 if ! _checkcert "$CA_CERT_PATH"; then 4905 _err "Can not get the ca cert." 4906 break 4907 fi 4908 cat "$CA_CERT_PATH" >>"$CERT_FULLCHAIN_PATH" 4909 rm -f "$CA_CERT_PATH.der" 4910 break 4911 fi 4912 fi 4913 _link_issuer_retry=$(_math $_link_issuer_retry + 1) 4914 _sleep "$_link_issuer_retry" 4915 done 4916 if [ "$_link_issuer_retry" = "$_MAX_ISSUER_RETRY" ]; then 4917 _err "Max retry for issuer ca cert is reached." 4918 fi 4919 else 4920 _debug "No Le_LinkIssuer header found." 4921 fi 4922 fi 4923 [ -f "$CA_CERT_PATH" ] && _info "The intermediate CA cert is in $(__green " $CA_CERT_PATH ")" 4924 [ -f "$CERT_FULLCHAIN_PATH" ] && _info "And the full chain certs is there: $(__green " $CERT_FULLCHAIN_PATH ")" 5005 [ -f "$CA_CERT_PATH" ] && _info "The intermediate CA cert is in: $(__green "$CA_CERT_PATH")" 5006 [ -f "$CERT_FULLCHAIN_PATH" ] && _info "And the full chain certs is there: $(__green "$CERT_FULLCHAIN_PATH")" 4925 5007 4926 5008 Le_CertCreateTime=$(_time) … … 5033 5115 . "$DOMAIN_CONF" 5034 5116 _debug Le_API "$Le_API" 5035 5036 if [ "$Le_API" = "$LETSENCRYPT_CA_V1" ]; then 5037 _cleardomainconf Le_API 5038 Le_API="$DEFAULT_CA" 5039 fi 5040 if [ "$Le_API" = "$LETSENCRYPT_STAGING_CA_V1" ]; then 5041 _cleardomainconf Le_API 5042 Le_API="$DEFAULT_STAGING_CA" 5117 if [ -z "$Le_API" ] || [ "$CA_LETSENCRYPT_V1" = "$Le_API" ]; then 5118 #if this is from an old version, Le_API is empty, 5119 #so, we force to use letsencrypt server 5120 Le_API="$CA_LETSENCRYPT_V2" 5043 5121 fi 5044 5122 5045 5123 if [ "$Le_API" ]; then 5124 if [ "$Le_API" != "$ACME_DIRECTORY" ]; then 5125 _clearAPI 5126 fi 5046 5127 export ACME_DIRECTORY="$Le_API" 5047 5128 #reload ca configs … … 5051 5132 _debug3 "initpath again." 5052 5133 _initpath "$Le_Domain" "$_isEcc" 5134 _initAPI 5053 5135 fi 5054 5136 … … 5219 5301 _local_addr="${11}" 5220 5302 _challenge_alias="${12}" 5303 _preferred_chain="${13}" 5221 5304 5222 5305 _csrsubj=$(_readSubjectFromCSR "$_csrfile") … … 5256 5339 fi 5257 5340 5258 if [ -z "$ACME_VERSION" ] && _contains "$_csrsubj,$_csrdomainlist" "*."; then5259 export ACME_VERSION=25260 fi5261 5341 _initpath "$_csrsubj" "$_csrkeylength" 5262 5342 mkdir -p "$DOMAIN_PATH" … … 5265 5345 cp "$_csrfile" "$CSR_PATH" 5266 5346 5267 issue "$_csrW" "$_csrsubj" "$_csrdomainlist" "$_csrkeylength" "$_real_cert" "$_real_key" "$_real_ca" "$_reload_cmd" "$_real_fullchain" "$_pre_hook" "$_post_hook" "$_renew_hook" "$_local_addr" "$_challenge_alias" 5347 issue "$_csrW" "$_csrsubj" "$_csrdomainlist" "$_csrkeylength" "$_real_cert" "$_real_key" "$_real_ca" "$_reload_cmd" "$_real_fullchain" "$_pre_hook" "$_post_hook" "$_renew_hook" "$_local_addr" "$_challenge_alias" "$_preferred_chain" 5268 5348 5269 5349 } … … 5468 5548 5469 5549 if [ "$_real_cert" ]; then 5470 _info "Installing cert to: $_real_cert"5550 _info "Installing cert to: $_real_cert" 5471 5551 if [ -f "$_real_cert" ] && [ ! "$_ACME_IS_RENEW" ]; then 5472 5552 cp "$_real_cert" "$_backup_path/cert.bak" … … 5476 5556 5477 5557 if [ "$_real_ca" ]; then 5478 _info "Installing CA to: $_real_ca"5558 _info "Installing CA to: $_real_ca" 5479 5559 if [ "$_real_ca" = "$_real_cert" ]; then 5480 5560 echo "" >>"$_real_ca" … … 5489 5569 5490 5570 if [ "$_real_key" ]; then 5491 _info "Installing key to: $_real_key"5571 _info "Installing key to: $_real_key" 5492 5572 if [ -f "$_real_key" ] && [ ! "$_ACME_IS_RENEW" ]; then 5493 5573 cp "$_real_key" "$_backup_path/key.bak" … … 5502 5582 5503 5583 if [ "$_real_fullchain" ]; then 5504 _info "Installing full chain to: $_real_fullchain"5584 _info "Installing full chain to: $_real_fullchain" 5505 5585 if [ -f "$_real_fullchain" ] && [ ! "$_ACME_IS_RENEW" ]; then 5506 5586 cp "$_real_fullchain" "$_backup_path/fullchain.bak" … … 5670 5750 cr="$($_CRONTAB -l | grep "$PROJECT_ENTRY --cron")" 5671 5751 if [ "$cr" ]; then 5672 if _exists uname && uname -a | grep solaris>/dev/null; then5752 if _exists uname && uname -a | grep SunOS >/dev/null; then 5673 5753 $_CRONTAB -l | sed "/$PROJECT_ENTRY --cron/d" | $_CRONTAB -- 5674 5754 else … … 5710 5790 fi 5711 5791 5792 . "$DOMAIN_CONF" 5793 _debug Le_API "$Le_API" 5794 5795 if [ "$Le_API" ]; then 5796 if [ "$Le_API" != "$ACME_DIRECTORY" ]; then 5797 _clearAPI 5798 fi 5799 export ACME_DIRECTORY="$Le_API" 5800 #reload ca configs 5801 ACCOUNT_KEY_PATH="" 5802 ACCOUNT_JSON_PATH="" 5803 CA_CONF="" 5804 _debug3 "initpath again." 5805 _initpath "$Le_Domain" "$_isEcc" 5806 _initAPI 5807 fi 5808 5712 5809 cert="$(_getfile "${CERT_PATH}" "${BEGIN_CERT}" "${END_CERT}" | tr -d "\r\n" | _url_replace)" 5713 5810 … … 5719 5816 _initAPI 5720 5817 5721 if [ "$ACME_VERSION" = "2" ]; then 5722 data="{\"certificate\": \"$cert\",\"reason\":$_reason}" 5723 else 5724 data="{\"resource\": \"revoke-cert\", \"certificate\": \"$cert\"}" 5725 fi 5818 data="{\"certificate\": \"$cert\",\"reason\":$_reason}" 5819 5726 5820 uri="${ACME_REVOKE_CERT}" 5727 5821 … … 5792 5886 _d_domain="$1" 5793 5887 _d_type="$2" 5794 _initpath 5795 5796 if [ "$ACME_VERSION" = "2" ]; then 5797 _identifiers="{\"type\":\"dns\",\"value\":\"$_d_domain\"}" 5798 if ! _send_signed_request "$ACME_NEW_ORDER" "{\"identifiers\": [$_identifiers]}"; then 5799 _err "Can not get domain new order." 5800 return 1 5801 fi 5802 _authorizations_seg="$(echo "$response" | _egrep_o '"authorizations" *: *\[[^\]*\]' | cut -d '[' -f 2 | tr -d ']' | tr -d '"')" 5803 _debug2 _authorizations_seg "$_authorizations_seg" 5804 if [ -z "$_authorizations_seg" ]; then 5805 _err "_authorizations_seg not found." 5806 _clearup 5807 _on_issue_err "$_post_hook" 5808 return 1 5809 fi 5810 5811 authzUri="$_authorizations_seg" 5812 _debug2 "authzUri" "$authzUri" 5813 if ! _send_signed_request "$authzUri"; then 5814 _err "get to authz error." 5815 _err "_authorizations_seg" "$_authorizations_seg" 5816 _err "authzUri" "$authzUri" 5817 _clearup 5818 _on_issue_err "$_post_hook" 5819 return 1 5820 fi 5821 5822 response="$(echo "$response" | _normalizeJson)" 5823 _debug2 response "$response" 5824 _URL_NAME="url" 5825 else 5826 if ! __get_domain_new_authz "$_d_domain"; then 5827 _err "Can not get domain new authz token." 5828 return 1 5829 fi 5830 5831 authzUri="$(echo "$responseHeaders" | grep "^Location:" | _head_n 1 | cut -d ':' -f 2- | tr -d "\r\n")" 5832 _debug "authzUri" "$authzUri" 5833 if [ "$code" ] && [ ! "$code" = '201' ]; then 5834 _err "new-authz error: $response" 5835 return 1 5836 fi 5837 _URL_NAME="uri" 5838 fi 5839 5840 entries="$(echo "$response" | tr '][' '==' | _egrep_o "challenges\": *=[^=]*=" | tr '}{' '\n' | grep "\"status\": *\"valid\"")" 5888 _initpath "$_d_domain" "$_d_type" 5889 5890 . "$DOMAIN_CONF" 5891 _debug Le_API "$Le_API" 5892 5893 if [ "$Le_API" ]; then 5894 if [ "$Le_API" != "$ACME_DIRECTORY" ]; then 5895 _clearAPI 5896 fi 5897 export ACME_DIRECTORY="$Le_API" 5898 #reload ca configs 5899 ACCOUNT_KEY_PATH="" 5900 ACCOUNT_JSON_PATH="" 5901 CA_CONF="" 5902 _debug3 "initpath again." 5903 _initpath "$Le_Domain" "$_d_type" 5904 _initAPI 5905 fi 5906 5907 _identifiers="{\"type\":\"dns\",\"value\":\"$_d_domain\"}" 5908 if ! _send_signed_request "$ACME_NEW_ORDER" "{\"identifiers\": [$_identifiers]}"; then 5909 _err "Can not get domain new order." 5910 return 1 5911 fi 5912 _authorizations_seg="$(echo "$response" | _egrep_o '"authorizations" *: *\[[^\]*\]' | cut -d '[' -f 2 | tr -d ']' | tr -d '"')" 5913 _debug2 _authorizations_seg "$_authorizations_seg" 5914 if [ -z "$_authorizations_seg" ]; then 5915 _err "_authorizations_seg not found." 5916 _clearup 5917 _on_issue_err "$_post_hook" 5918 return 1 5919 fi 5920 5921 authzUri="$_authorizations_seg" 5922 _debug2 "authzUri" "$authzUri" 5923 if ! _send_signed_request "$authzUri"; then 5924 _err "get to authz error." 5925 _err "_authorizations_seg" "$_authorizations_seg" 5926 _err "authzUri" "$authzUri" 5927 _clearup 5928 _on_issue_err "$_post_hook" 5929 return 1 5930 fi 5931 5932 response="$(echo "$response" | _normalizeJson)" 5933 _debug2 response "$response" 5934 _URL_NAME="url" 5935 5936 entries="$(echo "$response" | tr '][' '==' | _egrep_o "challenges\": *=[^=]*=" | tr '}{' '\n\n' | grep "\"status\": *\"valid\"")" 5841 5937 if [ -z "$entries" ]; then 5842 5938 _info "No valid entries found." … … 5891 5987 _info "Deactivate: $_vtype" 5892 5988 5893 if [ "$ACME_VERSION" = "2" ]; then 5894 _djson="{\"status\":\"deactivated\"}" 5895 else 5896 _djson="{\"resource\": \"authz\", \"status\":\"deactivated\"}" 5897 fi 5989 _djson="{\"status\":\"deactivated\"}" 5898 5990 5899 5991 if _send_signed_request "$authzUri" "$_djson" && _contains "$response" '"deactivated"'; then … … 6102 6194 } 6103 6195 6104 # nocron confighome noprofile 6196 # nocron confighome noprofile accountemail 6105 6197 install() { 6106 6198 … … 6112 6204 _c_home="$2" 6113 6205 _noprofile="$3" 6206 _accountemail="$4" 6207 6114 6208 if ! _initpath; then 6115 6209 _err "Install failed." … … 6228 6322 done 6229 6323 fi 6324 fi 6325 6326 if [ "$_accountemail" ]; then 6327 _saveaccountconf "ACCOUNT_EMAIL" "$_accountemail" 6230 6328 fi 6231 6329 … … 6452 6550 --set-default-ca Used with '--server', Set the default CA to use. 6453 6551 See: $_SERVER_WIKI 6552 --set-default-chain Set the default preferred chain for a CA. 6553 See: $_PREFERRED_CHAIN_WIKI 6454 6554 6455 6555 … … 6508 6608 --config-home <directory> Specifies the home dir to save all the configurations. 6509 6609 --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.6610 -m, --email <email> Specifies the account email, only valid for the '--install' and '--update-account' command. 6511 6611 --accountkey <file> Specifies the account key path, only valid for the '--install' command. 6512 6612 --days <ndays> Specifies the days to renew the cert when using '--issue' command. The default value is $DEFAULT_RENEW days. … … 6519 6619 --ca-bundle <file> Specifies the path to the CA certificate bundle to verify api server's certificate. 6520 6620 --ca-path <directory> Specifies directory containing CA certificates in PEM format, used by wget or curl. 6521 --no cronOnly valid for '--install' command, which means: do not install the default cron job.6621 --no-cron Only valid for '--install' command, which means: do not install the default cron job. 6522 6622 In this case, the certs will not be renewed automatically. 6523 --no profileOnly valid for '--install' command, which means: do not install aliases to user profile.6623 --no-profile Only valid for '--install' command, which means: do not install aliases to user profile. 6524 6624 --no-color Do not output color text. 6525 6625 --force-color Force output of color text. Useful for non-interactive use with the aha tool for HTML E-Mails. … … 6559 6659 } 6560 6660 6561 # nocron noprofile 6562 _installOnline() { 6661 installOnline() { 6563 6662 _info "Installing from online archive." 6564 _nocron="$1" 6565 _ noprofile="$2"6566 if [ ! "$BRANCH" ]; then6567 BRANCH="master"6568 fi 6569 6570 target="$PROJECT/archive/$ BRANCH.tar.gz"6663 6664 _branch="$BRANCH" 6665 if [ -z "$_branch" ]; then 6666 _branch="master" 6667 fi 6668 6669 target="$PROJECT/archive/$_branch.tar.gz" 6571 6670 _info "Downloading $target" 6572 localname="$ BRANCH.tar.gz"6671 localname="$_branch.tar.gz" 6573 6672 if ! _get "$target" >$localname; then 6574 6673 _err "Download error." … … 6582 6681 fi 6583 6682 6584 cd "$PROJECT_NAME-$ BRANCH"6683 cd "$PROJECT_NAME-$_branch" 6585 6684 chmod +x $PROJECT_ENTRY 6586 if ./$PROJECT_ENTRY install "$_nocron" "" "$_noprofile"; then6685 if ./$PROJECT_ENTRY --install "$@"; then 6587 6686 _info "Install success!" 6588 6687 _initpath … … 6592 6691 cd .. 6593 6692 6594 rm -rf "$PROJECT_NAME-$ BRANCH"6693 rm -rf "$PROJECT_NAME-$_branch" 6595 6694 rm -f "$localname" 6596 6695 ) … … 6601 6700 shift 6602 6701 _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 46702 _get $_hash_url | tr -d "\r\n" | tr '{},' '\n\n\n' | grep '"sha":' | cut -d '"' -f 4 6604 6703 } 6605 6704 … … 6620 6719 export LE_WORKING_DIR 6621 6720 cd "$LE_WORKING_DIR" 6622 _installOnline "nocron" "noprofile"6721 installOnline "--nocron" "--noprofile" 6623 6722 ); then 6624 6723 _info "Upgrade success!" … … 6674 6773 } 6675 6774 6676 #server 6775 #server #keylength 6677 6776 _selectServer() { 6678 6777 _server="$1" 6778 _skeylength="$2" 6679 6779 _server_lower="$(echo "$_server" | _lower_case)" 6680 6780 _sindex=0 … … 6687 6787 _debug2 "_selectServer match $sname" 6688 6788 _serverdir="$(_getfield "$CA_SERVERS" $_sindex)" 6789 if [ "$_serverdir" = "$CA_SSLCOM_RSA" ] && _isEccKey "$_skeylength"; then 6790 _serverdir="$CA_SSLCOM_ECC" 6791 fi 6689 6792 _debug "Selected server: $_serverdir" 6690 6793 ACME_DIRECTORY="$_serverdir" … … 6703 6806 if [ -z "$caurl" ]; then 6704 6807 caurl="$DEFAULT_CA" 6808 fi 6809 if [ "$CA_SSLCOM_ECC" = "$caurl" ]; then 6810 caurl="$CA_SSLCOM_RSA" #just hack to get the short name 6705 6811 fi 6706 6812 caurl_lower="$(echo $caurl | _lower_case)" … … 6730 6836 _saveaccountconf "DEFAULT_ACME_SERVER" "$ACME_DIRECTORY" 6731 6837 _info "Changed default CA to: $(__green "$ACME_DIRECTORY")" 6838 } 6839 6840 #preferred-chain 6841 setdefaultchain() { 6842 _initpath 6843 _preferred_chain="$1" 6844 if [ -z "$_preferred_chain" ]; then 6845 _err "Please give a '--preferred-chain value' value." 6846 return 1 6847 fi 6848 mkdir -p "$CA_DIR" 6849 _savecaconf "DEFAULT_PREFERRED_CHAIN" "$_preferred_chain" 6732 6850 } 6733 6851 … … 6800 6918 _CMD="install" 6801 6919 ;; 6920 --install-online) 6921 shift 6922 installOnline "$@" 6923 return 6924 ;; 6802 6925 --uninstall) 6803 6926 _CMD="uninstall" … … 6877 7000 --set-default-ca) 6878 7001 _CMD="setdefaultca" 7002 ;; 7003 --set-default-chain) 7004 _CMD="setdefaultchain" 6879 7005 ;; 6880 7006 -d | --domain) … … 6891 7017 fi 6892 7018 6893 if _startswith "$_dvalue" "*."; then6894 _debug "Wildcard domain"6895 export ACME_VERSION=26896 fi6897 7019 if [ -z "$_domain" ]; then 6898 7020 _domain="$_dvalue" … … 6917 7039 --server) 6918 7040 _server="$2" 6919 _selectServer "$_server"6920 7041 shift 6921 7042 ;; … … 7016 7137 shift 7017 7138 ;; 7018 7019 7139 --keylength | -k) 7020 7140 _keylength="$2" … … 7025 7145 shift 7026 7146 ;; 7027 7028 7147 --cert-file | --certpath) 7029 7148 _cert_file="$2" … … 7074 7193 shift 7075 7194 ;; 7076 -m | -- accountemail)7195 -m | --email | --accountemail) 7077 7196 _accountemail="$2" 7078 ACCOUNT_EMAIL="$_accountemail"7197 export ACCOUNT_EMAIL="$_accountemail" 7079 7198 shift 7080 7199 ;; … … 7119 7238 shift 7120 7239 ;; 7121 --no cron)7240 --no-cron | --nocron) 7122 7241 _nocron="1" 7123 7242 ;; 7124 --no profile)7243 --no-profile | --noprofile) 7125 7244 _noprofile="1" 7126 7245 ;; … … 7288 7407 shift 1 7289 7408 done 7409 7410 if [ "$_server" ]; then 7411 _selectServer "$_server" "${_ecc:-$_keylength}" 7412 fi 7290 7413 7291 7414 if [ "${_CMD}" != "install" ]; then … … 7342 7465 _debug "Running cmd: ${_CMD}" 7343 7466 case "${_CMD}" in 7344 install) install "$_nocron" "$_confighome" "$_noprofile" ;;7467 install) install "$_nocron" "$_confighome" "$_noprofile" "$_accountemail" ;; 7345 7468 uninstall) uninstall "$_nocron" ;; 7346 7469 upgrade) upgrade ;; … … 7352 7475 ;; 7353 7476 signcsr) 7354 signcsr "$_csr" "$_webroot" "$_cert_file" "$_key_file" "$_ca_file" "$_reloadcmd" "$_fullchain_file" "$_pre_hook" "$_post_hook" "$_renew_hook" "$_local_address" "$_challenge_alias" 7477 signcsr "$_csr" "$_webroot" "$_cert_file" "$_key_file" "$_ca_file" "$_reloadcmd" "$_fullchain_file" "$_pre_hook" "$_post_hook" "$_renew_hook" "$_local_address" "$_challenge_alias" "$_preferred_chain" 7355 7478 ;; 7356 7479 showcsr) … … 7411 7534 setdefaultca 7412 7535 ;; 7536 setdefaultchain) 7537 setdefaultchain "$_preferred_chain" 7538 ;; 7413 7539 *) 7414 7540 if [ "$_CMD" ]; then … … 7455 7581 } 7456 7582 7457 if [ "$INSTALLONLINE" ]; then7458 INSTALLONLINE=""7459 _installOnline7460 exit7461 fi7462 7463 7583 main() { 7464 7584 [ -z "$1" ] && showhelp && return -
npl/syn3/acme/root/usr/bin/syn3-acme-issue
r7c410f9 r105afb5 15 15 16 16 if [ "$EXIT" == "0" ]; then 17 cat /usr/webint/ssl/server.crt /usr/webint/ssl/server. key> /usr/webint/ssl/certandkey.pem17 cat /usr/webint/ssl/server.crt /usr/webint/ssl/server.pem > /usr/webint/ssl/certandkey.pem 18 18 syn3-state certbot OK "SSL certificate valid." 19 19 fi -
npl/syn3/acme/root/usr/bin/syn3-acme-renew
r7c410f9 r105afb5 15 15 16 16 if [ "$EXIT" == "0" ]; then 17 cat /usr/webint/ssl/server.crt /usr/webint/ssl/server. key> /usr/webint/ssl/certandkey.pem17 cat /usr/webint/ssl/server.crt /usr/webint/ssl/server.pem > /usr/webint/ssl/certandkey.pem 18 18 syn3-state certbot OK "SSL certificate valid. `cat $STATUS`" 19 19 else -
npl/syn3/acme/syn3_acme.build
r7c410f9 r105afb5 1 1 01 12 -
npl/syn3/acme/syn3_acme.md5
r7c410f9 r105afb5 1 1 d41d8cd98f00b204e9800998ecf8427e ./root/etc/webint/SSL_DOMAINS.new 2 0418c2dac1c09a1e0a5a923de7155251./root/usr/bin/acme.sh2 41f48d3c2742cbbdf0fe9b7bf77740c0 ./root/usr/bin/acme.sh 3 3 a0e5403f61c08e4eda04cd2e61d7938a ./root/usr/bin/syn3-acme 4 59aa594e0d86791b3aa9b7b1a3e88e42 ./root/usr/bin/syn3-acme-issue5 917bbc278f45bd8ab36a946d4898dd0f./root/usr/bin/syn3-acme-renew6 0301b5ee1cb78f1410fe47edbf32e780./syn3_acme.pkg4 a6acd24402cd102ba0fa6698140dc0b2 ./root/usr/bin/syn3-acme-issue 5 4a90cca626fec2de3d266c94c0e7d321 ./root/usr/bin/syn3-acme-renew 6 8bf81f0d178c08b77421b11d71fcf347 ./syn3_acme.pkg 7 7 1a66f2a0cb707f264b0268ee3d4956d3 ./syn3_acme.SlackBuild 8 6c17d788610977961a07f821dad6ccc3./syn3_acme.SlackBuild.log.gz8 33724e469f08288ccd67b04f39cae180 ./syn3_acme.SlackBuild.log.gz -
npl/system/ca_certificates/ca-certificates.SlackBuild.orig
r7c410f9 r105afb5 1 #!/bin/ sh1 #!/bin/bash 2 2 3 3 # Slackware build script for ca-certificates 4 4 5 5 # Copyright 2009,2011 Robby Workman Northport, AL, USA 6 # Copyright 2012, 2013, 2015, 2016 Patrick J. Volkerding, Sebeka, MN, USA6 # Copyright 2012, 2013, 2015, 2016, 2018 Patrick J. Volkerding, Sebeka, MN, USA 7 7 # All rights reserved. 8 8 # … … 24 24 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 25 26 cd $(dirname $0) ; CWD=$(pwd) 27 26 28 PKGNAM=ca-certificates 27 VERSION=${VERSION:- 20161130}29 VERSION=${VERSION:-$(echo certdata-*.txt.xz | cut -f 2 -d - | cut -f 1 -d .)} 28 30 ARCH=noarch 29 31 BUILD=${BUILD:-1_slack14.2} 30 32 31 TARVERSION=${VERSION}+nmu1 33 # If the variable PRINT_PACKAGE_NAME is set, then this script will report what 34 # the name of the created package would be, and then exit. This information 35 # could be useful to other scripts. 36 if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then 37 echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" 38 exit 0 39 fi 32 40 33 CWD=$(pwd) 41 TARVERSION=${VERSION} 42 34 43 TMP=${TMP:-/tmp} 35 44 PKG=$TMP/package-$PKGNAM … … 39 48 cd $TMP 40 49 41 # Need both $PKGNAM and $PKGNAM-$VERSION since upstream can't decide how 42 # to package their tarball: 43 rm -rf $PKGNAM $PKGNAM-$VERSION 50 rm -rf $PKGNAM 44 51 45 52 # Extract the tarball: 46 tar xvf $CWD/${PKGNAM} _$TARVERSION.tar.?z || exit 153 tar xvf $CWD/${PKGNAM}.tar.?z || exit 1 47 54 48 # Again, both $PKGNAM and $PKGNAM-$VERSION are needed here: 49 cd $PKGNAM-$VERSION || cd $PKGNAM || exit 1 55 cd $PKGNAM || exit 1 50 56 51 57 chown -R root:root . … … 56 62 -exec chmod 644 {} \; 57 63 58 # Obsolete?59 #zcat $CWD/patches/fixup_DESTDIR.diff.gz | patch -p1 || exit 164 # Remove incompatible command operators used to call 'run-parts': 65 zcat $CWD/fixup_update-ca-certificates.diff.gz | patch -p1 || exit 1 60 66 61 # Remove incompatible command operators used to call 'run-parts': 62 zcat $CWD/patches/fixup_update-ca-certificates.diff.gz | patch -p1 || exit 1 67 # Use "c_rehash" rather than "openssl rehash". They act mostly the same, but 68 # the openssl builtin is not available on older versions of Slackware, while 69 # c_rehash will always be there. 70 zcat $CWD/update-ca-certificates.c_rehash.diff.gz | patch -p1 || exit 1 71 72 # Update to certdata.txt from $CWD: 73 xzcat $CWD/certdata-${VERSION}.txt.xz > mozilla/certdata.txt 63 74 64 75 make || exit 1 65 76 make install DESTDIR=$PKG || exit 1 66 77 78 # Remove expired certificate: 79 if [ -r $PKG//usr/share/ca-certificates/mozilla/DST_Root_CA_X3.crt ]; then 80 rm -f $PKG//usr/share/ca-certificates/mozilla/DST_Root_CA_X3.crt 81 fi 82 67 83 mkdir -p $PKG/etc/ca-certificates/update.d 68 84 printf "# Automatically generated by $PKGNAM-$VERSION \n#\n" \ 69 > $PKG/etc/ca-certificates.conf .new85 > $PKG/etc/ca-certificates.conf 70 86 ( cd $PKG/usr/share/ca-certificates 71 87 find . -name '*.crt' | sort | cut -b3- 72 ) >> $PKG/etc/ca-certificates.conf .new88 ) >> $PKG/etc/ca-certificates.conf 73 89 74 90 mkdir -p $PKG/usr/man/man8 … … 77 93 78 94 mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION 79 mv debian/NEWS debian/NEWS.Debian 80 cp -a debian/NEWS.Debian debian/README.Debian $PKG/usr/doc/$PKGNAM-$VERSION 95 cp -a docs/* $PKG/usr/doc/$PKGNAM-$VERSION 81 96 82 97 mkdir -p $PKG/var/log/setup -
npl/system/ca_certificates/ca_certificates.SlackBuild
r7c410f9 r105afb5 3 3 # Automaticly created by importpackage v1.0 4 4 # Imported from: https://mirrors.slackware.com/slackware/slackware-14.2/patches/source/ca-certificates/ 5 # Created at Thu Sep 20 18:32:49 CEST 20185 # Created at ma 29 nov 2021 11:53:10 CET 6 6 7 7 … … 11 11 source ./ca-certificates.SlackBuild.orig 12 12 13 mkdir -p /tmp/package-ca-certificates/etc/cron.weekly14 ln -s /usr/sbin/update-ca-certificates /tmp/package-ca-certificates/etc/cron.weekly15 13 16 14 ############ make syn3 packages -
npl/system/ca_certificates/ca_certificates.build
r7c410f9 r105afb5 1 6 1 7 -
npl/system/ca_certificates/ca_certificates.md5
r7c410f9 r105afb5 1 a09e8b63126188fd0ed77f6fbaf5d35f ./ca-certificates_20161130+nmu1.tar.xz 2 f357913107c91908803032be7651db56 ./ca_certificates_dev.pkg 3 b32269196c2fa44651fb14b021430eec ./ca_certificates.pkg 4 6cb73b8350729401c29f1b2e15cff2b8 ./ca_certificates.SlackBuild 5 5d289f1bc67afe47662457accc53963d ./ca_certificates.SlackBuild.log.gz 6 c23d716a27384ed57c9085d400d4cbf9 ./ca-certificates.SlackBuild.orig 7 d14bfbd360d69256b0f5a916301fdb5a ./doinst.sh.gz 8 260654f21ca5431270192d94f421cfc2 ./patches/fixup_DESTDIR.diff.gz 9 cc23ac9b45fa4649ade60f64fe02eb7d ./patches/fixup_update-ca-certificates.diff.gz 1 c503ec33059aacb4f4a88081cc2bd969 ./ca_certificates_dev.pkg 2 1c80d0320a10ae55a9122f1053cd2074 ./ca_certificates.pkg 3 bdb5f5c4ba574445ab0819e345f42081 ./ca_certificates.SlackBuild 4 648c1c4d1fbd9ded03c092cb18607fe7 ./ca_certificates.SlackBuild.log.gz 5 b0263ee8f963696cf657d84d49a13ed5 ./ca-certificates.SlackBuild.orig 6 a36a44cf0586536772c200fd9ee10fa7 ./ca-certificates.tar.xz 7 54a1ef614be13310a71f99a506d522bc ./certdata-20211005.txt.xz 8 2bc10162481837f7b4c8c7532dca0854 ./doinst.sh.gz 9 cc23ac9b45fa4649ade60f64fe02eb7d ./fixup_update-ca-certificates.diff.gz 10 90833611bbc0db730880e8eb4ca7ca97 ./get-certdata.txt.sh 10 11 5dbe990e59d512ceb425ea6475ef0ae0 ./setup.11.cacerts 11 026b3a65d346d6d845f3497819b42fdb ./slack-desc 12 95c835581d5db3a3188e00f437d83dec ./slack-desc 13 e64b203a2dc95ad7de22be3f7e6d4739 ./update-ca-certificates.c_rehash.diff.gz -
npl/system/ca_certificates/ca_certificates.pkg
-
Property
mode
changed from
100755
to100644
-
Property
mode
changed from
-
npl/system/ca_certificates/ca_certificates.version
r7c410f9 r105afb5 1 20 1611301 20211005 -
npl/system/ca_certificates/ca_certificates_dev.build
r7c410f9 r105afb5 1 6 1 7 -
npl/system/ca_certificates/ca_certificates_dev.version
r7c410f9 r105afb5 1 20 1611301 20211005 -
npl/system/ca_certificates/slack-desc
r7c410f9 r105afb5 1 1 # HOW TO EDIT THIS FILE: 2 # The "handy ruler" below makes it easier to edit a package description. 2 # The "handy ruler" below makes it easier to edit a package description. Line 3 3 # up the first '|' above the ':' following the base package name, and the '|' 4 # on the right side marks the last column you can put a character in. 5 # make exactly 11 lines for the formatting to be correct. 4 # on the right side marks the last column you can put a character in. You must 5 # make exactly 11 lines for the formatting to be correct. It's also 6 6 # customary to leave one space after the ':'. 7 7 … … 12 12 ca-certificates: applications to check for the authenticity of SSL connections. 13 13 ca-certificates: 14 ca-certificates: Homepage: http://packages.qa.debian.org/c/ca-certificates.html15 14 ca-certificates: 16 15 ca-certificates: … … 18 17 ca-certificates: 19 18 ca-certificates: 19 ca-certificates:
Note: See TracChangeset
for help on using the changeset viewer.