mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-12-22 13:11:41 +00:00
Update to work with new one.com procedure
Since some Months, its no longer possible to add TXT Records with the Name "_acme-challenge" to the base domain. To override the fallback value, you must use a CNAME and proxy it. For example. CNAME _acme-challenge.yourdomain.com => proxy_acme-challenge.yourdomain.com The TXT Records have to be created on proxy_acme-challenge.yourdomain.com Since the default CNAME TTL is 3600 seconds, it is recommended to leave the CNAME record. But if you would like to use the build-in SSL (for your web-site etc.) from one.com, you have to delete the record. A new variable "ONECOM_KeepCnameProxy" you can set in the account.conf is used to keep the CNAME record. By default the CNAME record will be removed. For ex.: SAVED_ONECOM_KeepCnameProxy='1' to keep the CNAME Record and speedup the process.
This commit is contained in:
parent
47a38a8977
commit
5fac282ee0
@ -5,7 +5,7 @@
|
|||||||
# Author: github: @diseq
|
# Author: github: @diseq
|
||||||
# Created: 2019-02-17
|
# Created: 2019-02-17
|
||||||
# Fixed by: @der-berni
|
# Fixed by: @der-berni
|
||||||
# Modified: 2019-05-31
|
# Modified: 2020-04-07
|
||||||
#
|
#
|
||||||
# export ONECOM_User="username"
|
# export ONECOM_User="username"
|
||||||
# export ONECOM_Password="password"
|
# export ONECOM_Password="password"
|
||||||
@ -29,33 +29,46 @@ dns_one_add() {
|
|||||||
_err "root domain not found"
|
_err "root domain not found"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mysubdomain=$_sub_domain
|
subdomain="${_sub_domain}"
|
||||||
mydomain=$_domain
|
maindomain=${_domain}
|
||||||
_debug mysubdomain "$mysubdomain"
|
|
||||||
_debug mydomain "$mydomain"
|
useProxy=0
|
||||||
|
if [ "${_sub_domain}" = "_acme-challenge" ]; then
|
||||||
# get entries
|
subdomain="proxy${_sub_domain}"
|
||||||
response="$(_get "https://www.one.com/admin/api/domains/$mydomain/dns/custom_records")"
|
useProxy=1
|
||||||
_debug response "$response"
|
fi
|
||||||
|
|
||||||
# Update the IP address for domain entry
|
_debug subdomain "$subdomain"
|
||||||
postdata="{\"type\":\"dns_custom_records\",\"attributes\":{\"priority\":0,\"ttl\":600,\"type\":\"TXT\",\"prefix\":\"$mysubdomain\",\"content\":\"$txtvalue\"}}"
|
_debug maindomain "$maindomain"
|
||||||
_debug postdata "$postdata"
|
|
||||||
response="$(_post "$postdata" "https://www.one.com/admin/api/domains/$mydomain/dns/custom_records" "" "POST" "application/json")"
|
if [ $useProxy -eq 1 ]; then
|
||||||
response="$(echo "$response" | _normalizeJson)"
|
#Check if the CNAME exists
|
||||||
_debug response "$response"
|
_dns_one_getrecord "CNAME" "$_sub_domain" "$subdomain.$maindomain"
|
||||||
|
if [ -z "$id" ]; then
|
||||||
id=$(echo "$response" | sed -n "s/{\"result\":{\"data\":{\"type\":\"dns_custom_records\",\"id\":\"\([^\"]*\)\",\"attributes\":{\"prefix\":\"$mysubdomain\",\"type\":\"TXT\",\"content\":\"$txtvalue\",\"priority\":0,\"ttl\":600}}},\"metadata\":null}/\1/p")
|
_info "$(__red "Add CNAME Proxy record: '$(__green "\"$_sub_domain\" => \"$subdomain.$maindomain\"")'")"
|
||||||
|
_dns_one_addrecord "CNAME" "$_sub_domain" "$subdomain.$maindomain"
|
||||||
if [ -z "$id" ]; then
|
|
||||||
_err "Add txt record error."
|
_info "Not valid yet, let's wait 1 hour to take effect."
|
||||||
return 1
|
_sleep 3600
|
||||||
else
|
fi
|
||||||
_info "Added, OK ($id)"
|
fi
|
||||||
|
|
||||||
|
#Check if the TXT exists
|
||||||
|
_dns_one_getrecord "TXT" "$subdomain" "$txtvalue"
|
||||||
|
if [ ! -z "$id" ]; then
|
||||||
|
_info "$(__green "Txt record with the same value found. Skip adding.")"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
_dns_one_addrecord "TXT" "$subdomain" "$txtvalue"
|
||||||
|
if [ -z "$id" ]; then
|
||||||
|
_err "Add CNAME record error."
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
_info "$(__green "Added, OK ($id)")"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dns_one_rm() {
|
dns_one_rm() {
|
||||||
@ -73,36 +86,46 @@ dns_one_rm() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mysubdomain=$_sub_domain
|
subdomain="${_sub_domain}"
|
||||||
mydomain=$_domain
|
maindomain=${_domain}
|
||||||
_debug mysubdomain "$mysubdomain"
|
|
||||||
_debug mydomain "$mydomain"
|
useProxy=0
|
||||||
|
if [ "${_sub_domain}" = "_acme-challenge" ]; then
|
||||||
# get entries
|
subdomain="proxy${_sub_domain}"
|
||||||
response="$(_get "https://www.one.com/admin/api/domains/$mydomain/dns/custom_records")"
|
useProxy=1
|
||||||
response="$(echo "$response" | _normalizeJson)"
|
fi
|
||||||
_debug response "$response"
|
|
||||||
|
_debug subdomain "$subdomain"
|
||||||
id=$(printf -- "%s" "$response" | sed -n "s/.*{\"type\":\"dns_custom_records\",\"id\":\"\([^\"]*\)\",\"attributes\":{\"prefix\":\"$mysubdomain\",\"type\":\"TXT\",\"content\":\"$txtvalue\",\"priority\":0,\"ttl\":600}.*/\1/p")
|
_debug maindomain "$maindomain"
|
||||||
|
if [ $useProxy -eq 1 ]; then
|
||||||
|
if [ "$ONECOM_KeepCnameProxy" = "1" ]; then
|
||||||
|
_info "$(__red "Keeping CNAME Proxy record: '$(__green "\"$_sub_domain\" => \"$subdomain.$maindomain\"")'")"
|
||||||
|
else
|
||||||
|
#Check if the CNAME exists
|
||||||
|
_dns_one_getrecord "CNAME" "$_sub_domain" "$subdomain.$maindomain"
|
||||||
|
if [ ! -z "$id" ]; then
|
||||||
|
_info "$(__red "Removing CNAME Proxy record: '$(__green "\"$_sub_domain\" => \"$subdomain.$maindomain\"")'")"
|
||||||
|
_dns_one_delrecord "$id"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Check if the TXT exists
|
||||||
|
_dns_one_getrecord "TXT" "$subdomain" "$txtvalue"
|
||||||
if [ -z "$id" ]; then
|
if [ -z "$id" ]; then
|
||||||
_err "Txt record not found."
|
_err "Txt record not found."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# delete entry
|
# delete entry
|
||||||
response="$(_post "$postdata" "https://www.one.com/admin/api/domains/$mydomain/dns/custom_records/$id" "" "DELETE" "application/json")"
|
|
||||||
response="$(echo "$response" | _normalizeJson)"
|
if _dns_one_delrecord "$id"; then
|
||||||
_debug response "$response"
|
_info "$(__green Removed, OK)"
|
||||||
|
return 0
|
||||||
if [ "$response" = '{"result":null,"metadata":null}' ]; then
|
|
||||||
_info "Removed, OK"
|
|
||||||
return 0
|
|
||||||
else
|
else
|
||||||
_err "Removing txt record error."
|
_err "Removing txt record error."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#_acme-challenge.www.domain.com
|
#_acme-challenge.www.domain.com
|
||||||
@ -138,6 +161,7 @@ _get_root() {
|
|||||||
_dns_one_login() {
|
_dns_one_login() {
|
||||||
|
|
||||||
# get credentials
|
# get credentials
|
||||||
|
ONECOM_KeepCnameProxy="${ONECOM_KeepCnameProxy:-$(_readaccountconf_mutable ONECOM_KeepCnameProxy)}"
|
||||||
ONECOM_User="${ONECOM_User:-$(_readaccountconf_mutable ONECOM_User)}"
|
ONECOM_User="${ONECOM_User:-$(_readaccountconf_mutable ONECOM_User)}"
|
||||||
ONECOM_Password="${ONECOM_Password:-$(_readaccountconf_mutable ONECOM_Password)}"
|
ONECOM_Password="${ONECOM_Password:-$(_readaccountconf_mutable ONECOM_Password)}"
|
||||||
if [ -z "$ONECOM_User" ] || [ -z "$ONECOM_Password" ]; then
|
if [ -z "$ONECOM_User" ] || [ -z "$ONECOM_Password" ]; then
|
||||||
@ -177,3 +201,76 @@ _dns_one_login() {
|
|||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_dns_one_getrecord() {
|
||||||
|
type="$1"
|
||||||
|
name="$2"
|
||||||
|
value="$3"
|
||||||
|
if [ -z "$type" ]; then
|
||||||
|
type="TXT"
|
||||||
|
fi
|
||||||
|
if [ -z "$name" ]; then
|
||||||
|
_err "Record name is empty."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
response="$(_get "https://www.one.com/admin/api/domains/$maindomain/dns/custom_records")"
|
||||||
|
response="$(echo "$response" | _normalizeJson)"
|
||||||
|
_debug response "$response"
|
||||||
|
|
||||||
|
if [ -z "${value}" ]; then
|
||||||
|
id=$(printf -- "%s" "$response" | sed -n "s/.*{\"type\":\"dns_custom_records\",\"id\":\"\([^\"]*\)\",\"attributes\":{\"prefix\":\"${name}\",\"type\":\"${type}\",\"content\":\"[^\"]*\",\"priority\":0,\"ttl\":600}.*/\1/p")
|
||||||
|
response=$(printf -- "%s" "$response" | sed -n "s/.*{\"type\":\"dns_custom_records\",\"id\":\"[^\"]*\",\"attributes\":{\"prefix\":\"${name}\",\"type\":\"${type}\",\"content\":\"\([^\"]*\)\",\"priority\":0,\"ttl\":600}.*/\1/p")
|
||||||
|
else
|
||||||
|
id=$(printf -- "%s" "$response" | sed -n "s/.*{\"type\":\"dns_custom_records\",\"id\":\"\([^\"]*\)\",\"attributes\":{\"prefix\":\"${name}\",\"type\":\"${type}\",\"content\":\"${value}\",\"priority\":0,\"ttl\":600}.*/\1/p")
|
||||||
|
fi
|
||||||
|
if [ -z "$id" ]; then
|
||||||
|
_err "Record not found."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
_dns_one_addrecord() {
|
||||||
|
type="$1"
|
||||||
|
name="$2"
|
||||||
|
value="$3"
|
||||||
|
if [ -z "$type" ]; then
|
||||||
|
type="TXT"
|
||||||
|
fi
|
||||||
|
if [ -z "$name" ]; then
|
||||||
|
_err "Record name is empty."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
postdata="{\"type\":\"dns_custom_records\",\"attributes\":{\"priority\":0,\"ttl\":600,\"type\":\"${type}\",\"prefix\":\"${name}\",\"content\":\"${value}\"}}"
|
||||||
|
_debug postdata "$postdata"
|
||||||
|
response="$(_post "$postdata" "https://www.one.com/admin/api/domains/$maindomain/dns/custom_records" "" "POST" "application/json")"
|
||||||
|
response="$(echo "$response" | _normalizeJson)"
|
||||||
|
_debug response "$response"
|
||||||
|
|
||||||
|
id=$(echo "$response" | sed -n "s/{\"result\":{\"data\":{\"type\":\"dns_custom_records\",\"id\":\"\([^\"]*\)\",\"attributes\":{\"prefix\":\"$subdomain\",\"type\":\"TXT\",\"content\":\"$txtvalue\",\"priority\":0,\"ttl\":600}}},\"metadata\":null}/\1/p")
|
||||||
|
|
||||||
|
if [ -z "$id" ]; then
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_dns_one_delrecord() {
|
||||||
|
id="$1"
|
||||||
|
if [ -z "$id" ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
response="$(_post "" "https://www.one.com/admin/api/domains/$maindomain/dns/custom_records/$id" "" "DELETE" "application/json")"
|
||||||
|
response="$(echo "$response" | _normalizeJson)"
|
||||||
|
_debug response "$response"
|
||||||
|
|
||||||
|
if [ "$response" = '{"result":null,"metadata":null}' ]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user