3 ############################################################
4 # KingHost API support #
5 # https://api.kinghost.net/doc/ #
7 # Author: Felipe Keller Braz <felipebraz@kinghost.com.br> #
8 # Report Bugs here: https://github.com/kinghost/acme.sh #
11 # export KINGHOST_Username="email@provider.com" #
12 # export KINGHOST_Password="xxxxxxxxxx" #
13 ############################################################
15 KING_Api
="https://api.kinghost.net/acme"
17 # Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
18 # Used to add txt record
23 KINGHOST_Username
="${KINGHOST_Username:-$(_readaccountconf_mutable KINGHOST_Username)}"
24 KINGHOST_Password
="${KINGHOST_Password:-$(_readaccountconf_mutable KINGHOST_Password)}"
25 if [ -z "$KINGHOST_Username" ] ||
[ -z "$KINGHOST_Password" ]; then
28 _err
"You don't specify KingHost api password and email yet."
29 _err
"Please create you key and try again."
33 #save the credentials to the account conf file.
34 _saveaccountconf_mutable KINGHOST_Username
"$KINGHOST_Username"
35 _saveaccountconf_mutable KINGHOST_Password
"$KINGHOST_Password"
37 _debug
"Getting txt records"
38 _kinghost_rest GET
"dns" "name=$fulldomain&content=$txtvalue"
40 #This API call returns "status":"ok" if dns record does not exist
41 #We are creating a new txt record here, so we expect the "ok" status
42 if ! echo "$response" |
grep '"status":"ok"' >/dev
/null
; then
48 _kinghost_rest POST
"dns" "name=$fulldomain&content=$txtvalue"
49 if ! echo "$response" |
grep '"status":"ok"' >/dev
/null
; then
58 # Usage: fulldomain txtvalue
59 # Used to remove the txt record after validation
64 KINGHOST_Password
="${KINGHOST_Password:-$(_readaccountconf_mutable KINGHOST_Password)}"
65 KINGHOST_Username
="${KINGHOST_Username:-$(_readaccountconf_mutable KINGHOST_Username)}"
66 if [ -z "$KINGHOST_Password" ] ||
[ -z "$KINGHOST_Username" ]; then
69 _err
"You don't specify KingHost api key and email yet."
70 _err
"Please create you key and try again."
74 _kinghost_rest DELETE
"dns" "name=$fulldomain&content=$txtvalue"
75 if ! echo "$response" |
grep '"status":"ok"' >/dev
/null
; then
84 #################### Private functions below ##################################
91 export _H1
="X-Auth-Email: $KINGHOST_Username"
92 export _H2
="X-Auth-Key: $KINGHOST_Password"
94 if [ "$method" != "GET" ]; then
96 response
="$(_post "$data" "$KING_Api/$uri.json
" "" "$method")"
98 response
="$(_get "$KING_Api/$uri.json?
$data")"
101 if [ "$?" != "0" ]; then
105 _debug2 response
"$response"