mirror of
https://github.com/plantroon/acme.sh.git
synced 2025-01-23 20:43:15 +00:00
commit
47359c1a3b
@ -315,12 +315,7 @@ You don't have to do anything manually!
|
|||||||
1. Azure DNS
|
1. Azure DNS
|
||||||
1. selectel.com(selectel.ru) DNS API
|
1. selectel.com(selectel.ru) DNS API
|
||||||
1. zonomi.com DNS API
|
1. zonomi.com DNS API
|
||||||
|
1. DreamHost.com API
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
And:
|
And:
|
||||||
|
|
||||||
|
4
acme.sh
4
acme.sh
@ -3598,6 +3598,10 @@ $_authorizations_map"
|
|||||||
_debug entry "$entry"
|
_debug entry "$entry"
|
||||||
if [ -z "$entry" ]; then
|
if [ -z "$entry" ]; then
|
||||||
_err "Error, can not get domain token entry $d"
|
_err "Error, can not get domain token entry $d"
|
||||||
|
_supported_vtypes="$(echo "$response" | _egrep_o "\"challenges\":\[[^]]*]" | tr '{' "\n" | grep type | cut -d '"' -f 4 | tr "\n" ' ')"
|
||||||
|
if [ "$_supported_vtypes" ]; then
|
||||||
|
_err "The supported validation types are: $_supported_vtypes, but you specified: $vtype"
|
||||||
|
fi
|
||||||
_clearup
|
_clearup
|
||||||
_on_issue_err "$_post_hook"
|
_on_issue_err "$_post_hook"
|
||||||
return 1
|
return 1
|
||||||
|
@ -744,6 +744,18 @@ acme.sh --issue --dns dns_zonomi -d example.com -d www.example.com
|
|||||||
|
|
||||||
The `ZM_Key` will be saved in `~/.acme.sh/account.conf` and will be reused when needed.
|
The `ZM_Key` will be saved in `~/.acme.sh/account.conf` and will be reused when needed.
|
||||||
|
|
||||||
|
## 40. Use DreamHost DNS API
|
||||||
|
|
||||||
|
DNS API keys may be created at https://panel.dreamhost.com/?tree=home.api.
|
||||||
|
Ensure the created key has add and remove privelages.
|
||||||
|
|
||||||
|
```
|
||||||
|
export DH_API_Key="<api key>"
|
||||||
|
acme.sh --issue --dns dns_dreamhost -d example.com -d www.example.com
|
||||||
|
```
|
||||||
|
|
||||||
|
The 'DH_API_KEY' will be saved in `~/.acme.sh/account.conf` and will
|
||||||
|
be reused when needed.
|
||||||
|
|
||||||
# Use custom API
|
# Use custom API
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ dns_ali_add() {
|
|||||||
fulldomain=$1
|
fulldomain=$1
|
||||||
txtvalue=$2
|
txtvalue=$2
|
||||||
|
|
||||||
|
Ali_Key="${Ali_Key:-$(_readaccountconf_mutable Ali_Key)}"
|
||||||
|
Ali_Secret="${Ali_Secret:-$(_readaccountconf_mutable Ali_Secret)}"
|
||||||
if [ -z "$Ali_Key" ] || [ -z "$Ali_Secret" ]; then
|
if [ -z "$Ali_Key" ] || [ -z "$Ali_Secret" ]; then
|
||||||
Ali_Key=""
|
Ali_Key=""
|
||||||
Ali_Secret=""
|
Ali_Secret=""
|
||||||
@ -18,8 +20,8 @@ dns_ali_add() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#save the api key and secret to the account conf file.
|
#save the api key and secret to the account conf file.
|
||||||
_saveaccountconf Ali_Key "$Ali_Key"
|
_saveaccountconf_mutable Ali_Key "$Ali_Key"
|
||||||
_saveaccountconf Ali_Secret "$Ali_Secret"
|
_saveaccountconf_mutable Ali_Secret "$Ali_Secret"
|
||||||
|
|
||||||
_debug "First detect the root zone"
|
_debug "First detect the root zone"
|
||||||
if ! _get_root "$fulldomain"; then
|
if ! _get_root "$fulldomain"; then
|
||||||
@ -32,6 +34,15 @@ dns_ali_add() {
|
|||||||
|
|
||||||
dns_ali_rm() {
|
dns_ali_rm() {
|
||||||
fulldomain=$1
|
fulldomain=$1
|
||||||
|
txtvalue=$2
|
||||||
|
Ali_Key="${Ali_Key:-$(_readaccountconf_mutable Ali_Key)}"
|
||||||
|
Ali_Secret="${Ali_Secret:-$(_readaccountconf_mutable Ali_Secret)}"
|
||||||
|
|
||||||
|
_debug "First detect the root zone"
|
||||||
|
if ! _get_root "$fulldomain"; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
_clean
|
_clean
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,16 +87,14 @@ _ali_rest() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
_debug2 response "$response"
|
||||||
if [ -z "$2" ]; then
|
if [ -z "$2" ]; then
|
||||||
message="$(printf "%s" "$response" | _egrep_o "\"Message\":\"[^\"]*\"" | cut -d : -f 2 | tr -d \")"
|
message="$(echo "$response" | _egrep_o "\"Message\":\"[^\"]*\"" | cut -d : -f 2 | tr -d \")"
|
||||||
if [ -n "$message" ]; then
|
if [ "$message" ]; then
|
||||||
_err "$message"
|
_err "$message"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_debug2 response "$response"
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ali_urlencode() {
|
_ali_urlencode() {
|
||||||
@ -112,12 +121,14 @@ _ali_nonce() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_check_exist_query() {
|
_check_exist_query() {
|
||||||
|
_qdomain="$1"
|
||||||
|
_qsubdomain="$2"
|
||||||
query=''
|
query=''
|
||||||
query=$query'AccessKeyId='$Ali_Key
|
query=$query'AccessKeyId='$Ali_Key
|
||||||
query=$query'&Action=DescribeDomainRecords'
|
query=$query'&Action=DescribeDomainRecords'
|
||||||
query=$query'&DomainName='$1
|
query=$query'&DomainName='$_qdomain
|
||||||
query=$query'&Format=json'
|
query=$query'&Format=json'
|
||||||
query=$query'&RRKeyWord=_acme-challenge'
|
query=$query'&RRKeyWord='$_qsubdomain
|
||||||
query=$query'&SignatureMethod=HMAC-SHA1'
|
query=$query'&SignatureMethod=HMAC-SHA1'
|
||||||
query=$query"&SignatureNonce=$(_ali_nonce)"
|
query=$query"&SignatureNonce=$(_ali_nonce)"
|
||||||
query=$query'&SignatureVersion=1.0'
|
query=$query'&SignatureVersion=1.0'
|
||||||
@ -169,17 +180,21 @@ _describe_records_query() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_clean() {
|
_clean() {
|
||||||
_check_exist_query "$_domain"
|
_check_exist_query "$_domain" "$_sub_domain"
|
||||||
if ! _ali_rest "Check exist records" "ignore"; then
|
if ! _ali_rest "Check exist records" "ignore"; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
records="$(echo "$response" -n | _egrep_o "\"RecordId\":\"[^\"]*\"" | cut -d : -f 2 | tr -d \")"
|
record_id="$(echo "$response" | tr '{' "\n" | grep "$_sub_domain" | grep "$txtvalue" | tr "," "\n" | grep RecordId | cut -d '"' -f 4)"
|
||||||
printf "%s" "$records" \
|
_debug2 record_id "$record_id"
|
||||||
| while read -r record_id; do
|
|
||||||
_delete_record_query "$record_id"
|
if [ -z "$record_id" ]; then
|
||||||
_ali_rest "Delete record $record_id" "ignore"
|
_debug "record not found, skip"
|
||||||
done
|
else
|
||||||
|
_delete_record_query "$record_id"
|
||||||
|
_ali_rest "Delete record $record_id" "ignore"
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_timestamp() {
|
_timestamp() {
|
||||||
|
@ -93,12 +93,7 @@ add_record() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if _contains "$response" "Action completed successful"; then
|
_contains "$response" "Action completed successful" || _contains "$response" "Domain record already exists"
|
||||||
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 1 #error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#################### Private functions below ##################################
|
#################### Private functions below ##################################
|
||||||
|
97
dnsapi/dns_dreamhost.sh
Normal file
97
dnsapi/dns_dreamhost.sh
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#Author: RhinoLance
|
||||||
|
#Report Bugs here: https://github.com/RhinoLance/acme.sh
|
||||||
|
#
|
||||||
|
|
||||||
|
#define the api endpoint
|
||||||
|
DH_API_ENDPOINT="https://api.dreamhost.com/"
|
||||||
|
querystring=""
|
||||||
|
|
||||||
|
######## Public functions #####################
|
||||||
|
|
||||||
|
#Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
|
||||||
|
dns_dreamhost_add() {
|
||||||
|
fulldomain=$1
|
||||||
|
txtvalue=$2
|
||||||
|
|
||||||
|
if ! validate "$fulldomain" "$txtvalue"; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
querystring="key=$DH_API_KEY&cmd=dns-add_record&record=$fulldomain&type=TXT&value=$txtvalue"
|
||||||
|
if ! submit "$querystring"; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
#Usage: fulldomain txtvalue
|
||||||
|
#Remove the txt record after validation.
|
||||||
|
dns_dreamhost_rm() {
|
||||||
|
fulldomain=$1
|
||||||
|
txtvalue=$2
|
||||||
|
|
||||||
|
if ! validate "$fulldomain" "$txtvalue"; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
querystring="key=$DH_API_KEY&cmd=dns-remove_record&record=$fulldomain&type=TXT&value=$txtvalue"
|
||||||
|
if ! submit "$querystring"; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
#################### Private functions below ##################################
|
||||||
|
|
||||||
|
#send the command to the api endpoint.
|
||||||
|
submit() {
|
||||||
|
querystring=$1
|
||||||
|
|
||||||
|
url="$DH_API_ENDPOINT?$querystring"
|
||||||
|
|
||||||
|
_debug url "$url"
|
||||||
|
|
||||||
|
if ! response="$(_get "$url")"; then
|
||||||
|
_err "Error <$1>"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$2" ]; then
|
||||||
|
message="$(echo "$response" | _egrep_o "\"Message\":\"[^\"]*\"" | cut -d : -f 2 | tr -d \")"
|
||||||
|
if [ -n "$message" ]; then
|
||||||
|
_err "$message"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
_debug response "$response"
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
#check that we have a valid API Key
|
||||||
|
validate() {
|
||||||
|
fulldomain=$1
|
||||||
|
txtvalue=$2
|
||||||
|
|
||||||
|
_info "Using dreamhost"
|
||||||
|
_debug fulldomain "$fulldomain"
|
||||||
|
_debug txtvalue "$txtvalue"
|
||||||
|
|
||||||
|
#retrieve the API key from the environment variable if it exists, otherwise look for a saved key.
|
||||||
|
DH_API_KEY="${DH_API_KEY:-$(_readaccountconf_mutable DH_API_KEY)}"
|
||||||
|
|
||||||
|
if [ -z "$DH_API_KEY" ]; then
|
||||||
|
DH_API_KEY=""
|
||||||
|
_err "You didn't specify the DreamHost api key yet (export DH_API_KEY=\"<api key>\")"
|
||||||
|
_err "Please login to your control panel, create a key and try again."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#save the api key to the account conf file.
|
||||||
|
_saveaccountconf_mutable DH_API_KEY "$DH_API_KEY"
|
||||||
|
}
|
@ -17,6 +17,8 @@ dns_lua_add() {
|
|||||||
fulldomain=$1
|
fulldomain=$1
|
||||||
txtvalue=$2
|
txtvalue=$2
|
||||||
|
|
||||||
|
LUA_Key="${LUA_Key:-$(_readaccountconf_mutable LUA_Key)}"
|
||||||
|
LUA_Email="${LUA_Email:-$(_readaccountconf_mutable LUA_Email)}"
|
||||||
if [ -z "$LUA_Key" ] || [ -z "$LUA_Email" ]; then
|
if [ -z "$LUA_Key" ] || [ -z "$LUA_Email" ]; then
|
||||||
LUA_Key=""
|
LUA_Key=""
|
||||||
LUA_Email=""
|
LUA_Email=""
|
||||||
@ -26,8 +28,8 @@ dns_lua_add() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#save the api key and email to the account conf file.
|
#save the api key and email to the account conf file.
|
||||||
_saveaccountconf LUA_Key "$LUA_Key"
|
_saveaccountconf_mutable LUA_Key "$LUA_Key"
|
||||||
_saveaccountconf LUA_Email "$LUA_Email"
|
_saveaccountconf_mutable LUA_Email "$LUA_Email"
|
||||||
|
|
||||||
_debug "First detect the root zone"
|
_debug "First detect the root zone"
|
||||||
if ! _get_root "$fulldomain"; then
|
if ! _get_root "$fulldomain"; then
|
||||||
@ -38,50 +40,26 @@ dns_lua_add() {
|
|||||||
_debug _sub_domain "$_sub_domain"
|
_debug _sub_domain "$_sub_domain"
|
||||||
_debug _domain "$_domain"
|
_debug _domain "$_domain"
|
||||||
|
|
||||||
_debug "Getting txt records"
|
_info "Adding record"
|
||||||
_LUA_rest GET "zones/${_domain_id}/records"
|
if _LUA_rest POST "zones/$_domain_id/records" "{\"type\":\"TXT\",\"name\":\"$fulldomain.\",\"content\":\"$txtvalue\",\"ttl\":120}"; then
|
||||||
|
if _contains "$response" "$fulldomain"; then
|
||||||
if ! _contains "$response" "\"id\":"; then
|
_info "Added"
|
||||||
_err "Error"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
count=$(printf "%s\n" "$response" | _egrep_o "\"name\":\"$fulldomain.\",\"type\":\"TXT\"" | wc -l | tr -d " ")
|
|
||||||
_debug count "$count"
|
|
||||||
if [ "$count" = "0" ]; then
|
|
||||||
_info "Adding record"
|
|
||||||
if _LUA_rest POST "zones/$_domain_id/records" "{\"type\":\"TXT\",\"name\":\"$fulldomain.\",\"content\":\"$txtvalue\",\"ttl\":120}"; then
|
|
||||||
if _contains "$response" "$fulldomain"; then
|
|
||||||
_info "Added"
|
|
||||||
#todo: check if the record takes effect
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
_err "Add txt record error."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
_err "Add txt record error."
|
|
||||||
else
|
|
||||||
_info "Updating record"
|
|
||||||
record_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":[^,]*,\"name\":\"$fulldomain.\",\"type\":\"TXT\"" | _head_n 1 | cut -d: -f2 | cut -d, -f1)
|
|
||||||
_debug "record_id" "$record_id"
|
|
||||||
|
|
||||||
_LUA_rest PUT "zones/$_domain_id/records/$record_id" "{\"id\":$record_id,\"type\":\"TXT\",\"name\":\"$fulldomain.\",\"content\":\"$txtvalue\",\"zone_id\":$_domain_id,\"ttl\":120}"
|
|
||||||
if [ "$?" = "0" ] && _contains "$response" "updated_at"; then
|
|
||||||
_info "Updated!"
|
|
||||||
#todo: check if the record takes effect
|
#todo: check if the record takes effect
|
||||||
return 0
|
return 0
|
||||||
|
else
|
||||||
|
_err "Add txt record error."
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
_err "Update error"
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#fulldomain
|
#fulldomain
|
||||||
dns_lua_rm() {
|
dns_lua_rm() {
|
||||||
fulldomain=$1
|
fulldomain=$1
|
||||||
txtvalue=$2
|
txtvalue=$2
|
||||||
|
|
||||||
|
LUA_Key="${LUA_Key:-$(_readaccountconf_mutable LUA_Key)}"
|
||||||
|
LUA_Email="${LUA_Email:-$(_readaccountconf_mutable LUA_Email)}"
|
||||||
_debug "First detect the root zone"
|
_debug "First detect the root zone"
|
||||||
if ! _get_root "$fulldomain"; then
|
if ! _get_root "$fulldomain"; then
|
||||||
_err "invalid domain"
|
_err "invalid domain"
|
||||||
|
@ -90,6 +90,10 @@ _initAuth() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$OVH_AK" != "$(_readaccountconf OVH_AK)" ]; then
|
||||||
|
_info "It seems that your ovh key is changed, let's clear consumer key first."
|
||||||
|
_clearaccountconf OVH_CK
|
||||||
|
fi
|
||||||
_saveaccountconf_mutable OVH_AK "$OVH_AK"
|
_saveaccountconf_mutable OVH_AK "$OVH_AK"
|
||||||
_saveaccountconf_mutable OVH_AS "$OVH_AS"
|
_saveaccountconf_mutable OVH_AS "$OVH_AS"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user