Skip to content

Commit 52ac922

Browse files
authored
Merge pull request #6611 from acmesh-official/dev
sync
2 parents 0a4500e + 4a7f35d commit 52ac922

File tree

2 files changed

+105
-3
lines changed

2 files changed

+105
-3
lines changed

acme.sh

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,7 @@ _createcsr() {
12711271
_savedomainconf Le_ExtKeyUse "$Le_ExtKeyUse"
12721272
printf "\nextendedKeyUsage=$Le_ExtKeyUse\n" >>"$csrconf"
12731273
else
1274-
printf "\nextendedKeyUsage=serverAuth,clientAuth\n" >>"$csrconf"
1274+
printf "\nextendedKeyUsage=serverAuth\n" >>"$csrconf"
12751275
fi
12761276

12771277
if [ "$acmeValidationv1" ]; then
@@ -1897,6 +1897,11 @@ _inithttp() {
18971897

18981898
if [ -z "$_ACME_CURL" ] && _exists "curl"; then
18991899
_ACME_CURL="curl --silent --dump-header $HTTP_HEADER "
1900+
if [ "$ACME_USE_IPV6_REQUESTS" ]; then
1901+
_ACME_CURL="$_ACME_CURL --ipv6 "
1902+
elif [ "$ACME_USE_IPV4_REQUESTS" ]; then
1903+
_ACME_CURL="$_ACME_CURL --ipv4 "
1904+
fi
19001905
if [ -z "$ACME_HTTP_NO_REDIRECTS" ]; then
19011906
_ACME_CURL="$_ACME_CURL -L "
19021907
fi
@@ -1924,6 +1929,11 @@ _inithttp() {
19241929

19251930
if [ -z "$_ACME_WGET" ] && _exists "wget"; then
19261931
_ACME_WGET="wget -q"
1932+
if [ "$ACME_USE_IPV6_REQUESTS" ]; then
1933+
_ACME_WGET="$_ACME_WGET --inet6-only "
1934+
elif [ "$ACME_USE_IPV4_REQUESTS" ]; then
1935+
_ACME_WGET="$_ACME_WGET --inet4-only "
1936+
fi
19271937
if [ "$ACME_HTTP_NO_REDIRECTS" ]; then
19281938
_ACME_WGET="$_ACME_WGET --max-redirect 0 "
19291939
fi
@@ -7137,6 +7147,8 @@ Parameters:
71377147
--auto-upgrade [0|1] Valid for '--upgrade' command, indicating whether to upgrade automatically in future. Defaults to 1 if argument is omitted.
71387148
--listen-v4 Force standalone/tls server to listen at ipv4.
71397149
--listen-v6 Force standalone/tls server to listen at ipv6.
7150+
--request-v4 Force client requests to use ipv4 to connect to the CA server.
7151+
--request-v6 Force client requests to use ipv6 to connect to the CA server.
71407152
--openssl-bin <file> Specifies a custom openssl bin location.
71417153
--use-wget Force to use wget, if you have both curl and wget installed.
71427154
--yes-I-know-dns-manual-mode-enough-go-ahead-please Force use of dns manual mode.
@@ -7255,6 +7267,24 @@ _processAccountConf() {
72557267
_saveaccountconf "ACME_USE_WGET" "$ACME_USE_WGET"
72567268
fi
72577269

7270+
if [ "$_request_v6" ]; then
7271+
_saveaccountconf "ACME_USE_IPV6_REQUESTS" "$_request_v6"
7272+
_clearaccountconf "ACME_USE_IPV4_REQUESTS"
7273+
ACME_USE_IPV4_REQUESTS=
7274+
elif [ "$_request_v4" ]; then
7275+
_saveaccountconf "ACME_USE_IPV4_REQUESTS" "$_request_v4"
7276+
_clearaccountconf "ACME_USE_IPV6_REQUESTS"
7277+
ACME_USE_IPV6_REQUESTS=
7278+
elif [ "$ACME_USE_IPV6_REQUESTS" ]; then
7279+
_saveaccountconf "ACME_USE_IPV6_REQUESTS" "$ACME_USE_IPV6_REQUESTS"
7280+
_clearaccountconf "ACME_USE_IPV4_REQUESTS"
7281+
ACME_USE_IPV4_REQUESTS=
7282+
elif [ "$ACME_USE_IPV4_REQUESTS" ]; then
7283+
_saveaccountconf "ACME_USE_IPV4_REQUESTS" "$ACME_USE_IPV4_REQUESTS"
7284+
_clearaccountconf "ACME_USE_IPV6_REQUESTS"
7285+
ACME_USE_IPV6_REQUESTS=
7286+
fi
7287+
72587288
}
72597289

72607290
_checkSudo() {
@@ -7420,6 +7450,8 @@ _process() {
74207450
_local_address=""
74217451
_log_level=""
74227452
_auto_upgrade=""
7453+
_request_v4=""
7454+
_request_v6=""
74237455
_listen_v4=""
74247456
_listen_v6=""
74257457
_openssl_bin=""
@@ -7885,6 +7917,18 @@ _process() {
78857917
fi
78867918
AUTO_UPGRADE="$_auto_upgrade"
78877919
;;
7920+
--request-v4)
7921+
_request_v4="1"
7922+
ACME_USE_IPV4_REQUESTS="1"
7923+
_request_v6=""
7924+
ACME_USE_IPV6_REQUESTS=""
7925+
;;
7926+
--request-v6)
7927+
_request_v6="1"
7928+
ACME_USE_IPV6_REQUESTS="1"
7929+
_request_v4=""
7930+
ACME_USE_IPV4_REQUESTS=""
7931+
;;
78887932
--listen-v4)
78897933
_listen_v4="1"
78907934
Le_Listen_V4="$_listen_v4"

dnsapi/dns_nanelo.sh

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,16 @@ dns_nanelo_add() {
2727
fi
2828
_saveaccountconf_mutable NANELO_TOKEN "$NANELO_TOKEN"
2929

30+
_debug "First detect the root zone"
31+
if ! _get_root "$fulldomain"; then
32+
_err "invalid domain"
33+
return 1
34+
fi
35+
_debug _sub_domain "$_sub_domain"
36+
_debug _domain "$_domain"
37+
3038
_info "Adding TXT record to ${fulldomain}"
31-
response="$(_get "$NANELO_API$NANELO_TOKEN/dns/addrecord?type=TXT&ttl=60&name=${fulldomain}&value=${txtvalue}")"
39+
response="$(_post "" "$NANELO_API$NANELO_TOKEN/dns/addrecord?domain=${_domain}&type=TXT&ttl=60&name=${_sub_domain}&value=${txtvalue}" "" "" "")"
3240
if _contains "${response}" 'success'; then
3341
return 0
3442
fi
@@ -51,12 +59,62 @@ dns_nanelo_rm() {
5159
fi
5260
_saveaccountconf_mutable NANELO_TOKEN "$NANELO_TOKEN"
5361

62+
_debug "First, let's detect the root zone:"
63+
if ! _get_root "$fulldomain"; then
64+
_err "invalid domain"
65+
return 1
66+
fi
67+
_debug _sub_domain "$_sub_domain"
68+
_debug _domain "$_domain"
69+
5470
_info "Deleting resource record $fulldomain"
55-
response="$(_get "$NANELO_API$NANELO_TOKEN/dns/deleterecord?type=TXT&ttl=60&name=${fulldomain}&value=${txtvalue}")"
71+
response="$(_post "" "$NANELO_API$NANELO_TOKEN/dns/deleterecord?domain=${_domain}&type=TXT&ttl=60&name=${_sub_domain}&value=${txtvalue}" "" "" "")"
5672
if _contains "${response}" 'success'; then
5773
return 0
5874
fi
5975
_err "Could not delete resource record, please check the logs"
6076
_err "${response}"
6177
return 1
6278
}
79+
80+
#################### Private functions below ##################################
81+
#_acme-challenge.www.domain.com
82+
#returns
83+
# _sub_domain=_acme-challenge.www
84+
# _domain=domain.com
85+
86+
_get_root() {
87+
fulldomain=$1
88+
89+
# Fetch all zones from Nanelo
90+
response="$(_get "$NANELO_API$NANELO_TOKEN/dns/getzones")" || return 1
91+
92+
# Extract "zones" array into space-separated list
93+
zones=$(echo "$response" |
94+
tr -d ' \n' |
95+
sed -n 's/.*"zones":\[\([^]]*\)\].*/\1/p' |
96+
tr -d '"' |
97+
tr , ' ')
98+
_debug zones "$zones"
99+
100+
bestzone=""
101+
for z in $zones; do
102+
case "$fulldomain" in
103+
*."$z" | "$z")
104+
if [ ${#z} -gt ${#bestzone} ]; then
105+
bestzone=$z
106+
fi
107+
;;
108+
esac
109+
done
110+
111+
if [ -z "$bestzone" ]; then
112+
_err "No matching zone found for $fulldomain"
113+
return 1
114+
fi
115+
116+
_domain="$bestzone"
117+
_sub_domain=$(printf "%s" "$fulldomain" | sed "s/\\.$_domain\$//")
118+
119+
return 0
120+
}

0 commit comments

Comments
 (0)