mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-12-25 14:41:40 +00:00
commit
c152b6f0ad
@ -358,7 +358,7 @@ You don't have to do anything manually!
|
||||
1. Rackspace Cloud DNS (https://www.rackspace.com)
|
||||
1. Online.net API (https://online.net/)
|
||||
1. MyDevil.net (https://www.mydevil.net/)
|
||||
|
||||
1. Core-Networks.de (https://core-networks.de)
|
||||
And:
|
||||
|
||||
**lexicon DNS API: https://github.com/Neilpang/acme.sh/wiki/How-to-use-lexicon-dns-api
|
||||
|
2
acme.sh
2
acme.sh
@ -1974,7 +1974,7 @@ _save_conf() {
|
||||
_sdkey="$2"
|
||||
_sdvalue="$3"
|
||||
_b64encode="$4"
|
||||
if [ "$_b64encode" ]; then
|
||||
if [ "$_sdvalue" ] && [ "$_b64encode" ]; then
|
||||
_sdvalue="${B64CONF_START}$(printf "%s" "${_sdvalue}" | _base64)${B64CONF_END}"
|
||||
fi
|
||||
if [ "$_s_c_f" ]; then
|
||||
|
@ -1279,6 +1279,26 @@ acme.sh --issue --dns dns_mydevil -d example.com -d *.example.com
|
||||
|
||||
After certificate is ready, you can install it with [deploy command](../deploy/README.md#14-deploy-your-cert-on-mydevilnet).
|
||||
|
||||
## 67. Use Core-Networks API to automatically issue cert
|
||||
|
||||
First you need to login to your Core-Networks account to to set up an API-User.
|
||||
Then export username and password to use these credentials.
|
||||
|
||||
```
|
||||
export CN_User="user"
|
||||
export CN_Password="passowrd"
|
||||
```
|
||||
|
||||
Ok, let's issue a cert now:
|
||||
```
|
||||
acme.sh --issue --dns dns_cn -d example.com -d www.example.com
|
||||
```
|
||||
|
||||
The `CN_User` and `CN_Password` will be saved in `~/.acme.sh/account.conf` and will be reused when needed.
|
||||
|
||||
|
||||
|
||||
|
||||
# Use custom API
|
||||
|
||||
If your API is not supported yet, you can write your own DNS API.
|
||||
@ -1300,3 +1320,5 @@ See: https://github.com/Neilpang/acme.sh/wiki/DNS-API-Dev-Guide
|
||||
# Use lexicon DNS API
|
||||
|
||||
https://github.com/Neilpang/acme.sh/wiki/How-to-use-lexicon-dns-api
|
||||
|
||||
|
||||
|
157
dnsapi/dns_cn.sh
Normal file
157
dnsapi/dns_cn.sh
Normal file
@ -0,0 +1,157 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# DNS API for acme.sh for Core-Networks (https://beta.api.core-networks.de/doc/).
|
||||
# created by 5ll and francis
|
||||
|
||||
CN_API="https://beta.api.core-networks.de"
|
||||
|
||||
######## Public functions #####################
|
||||
|
||||
dns_cn_add() {
|
||||
fulldomain=$1
|
||||
txtvalue=$2
|
||||
|
||||
if ! _cn_login; then
|
||||
_err "login failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
_debug "First detect the root zone"
|
||||
if ! _cn_get_root "$fulldomain"; then
|
||||
_err "invalid domain"
|
||||
return 1
|
||||
fi
|
||||
|
||||
_debug "_sub_domain $_sub_domain"
|
||||
_debug "_domain $_domain"
|
||||
|
||||
_info "Adding record"
|
||||
curData="{\"name\":\"$_sub_domain\",\"ttl\":120,\"type\":\"TXT\",\"data\":\"$txtvalue\"}"
|
||||
curResult="$(_post "${curData}" "${CN_API}/dnszones/${_domain}/records/")"
|
||||
|
||||
_debug "curData $curData"
|
||||
_debug "curResult $curResult"
|
||||
|
||||
if _contains "$curResult" ""; then
|
||||
_info "Added, OK"
|
||||
|
||||
if ! _cn_commit; then
|
||||
_err "commiting changes failed"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
|
||||
else
|
||||
_err "Add txt record error."
|
||||
_debug "curData is $curData"
|
||||
_debug "curResult is $curResult"
|
||||
_err "error adding text record, response was $curResult"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
dns_cn_rm() {
|
||||
fulldomain=$1
|
||||
txtvalue=$2
|
||||
|
||||
if ! _cn_login; then
|
||||
_err "login failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
_debug "First detect the root zone"
|
||||
if ! _cn_get_root "$fulldomain"; then
|
||||
_err "invalid domain"
|
||||
return 1
|
||||
fi
|
||||
|
||||
_info "Deleting record"
|
||||
curData="{\"name\":\"$_sub_domain\",\"data\":\"$txtvalue\"}"
|
||||
curResult="$(_post "${curData}" "${CN_API}/dnszones/${_domain}/records/delete")"
|
||||
_debug curData is "$curData"
|
||||
|
||||
_info "commiting changes"
|
||||
if ! _cn_commit; then
|
||||
_err "commiting changes failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
_info "Deletet txt record"
|
||||
return 0
|
||||
}
|
||||
|
||||
################### Private functions below ##################################
|
||||
_cn_login() {
|
||||
CN_User="${CN_User:-$(_readaccountconf_mutable CN_User)}"
|
||||
CN_Password="${CN_Password:-$(_readaccountconf_mutable CN_Password)}"
|
||||
if [ -z "$CN_User" ] || [ -z "$CN_Password" ]; then
|
||||
CN_User=""
|
||||
CN_Password=""
|
||||
_err "You must export variables: CN_User and CN_Password"
|
||||
return 1
|
||||
fi
|
||||
|
||||
#save the config variables to the account conf file.
|
||||
_saveaccountconf_mutable CN_User "$CN_User"
|
||||
_saveaccountconf_mutable CN_Password "$CN_Password"
|
||||
|
||||
_info "Getting an AUTH-Token"
|
||||
curData="{\"login\":\"${CN_User}\",\"password\":\"${CN_Password}\"}"
|
||||
curResult="$(_post "${curData}" "${CN_API}/auth/token")"
|
||||
_debug "Calling _CN_login: '${curData}' '${CN_API}/auth/token'"
|
||||
|
||||
if _contains "${curResult}" '"token":"'; then
|
||||
authToken=$(echo "${curResult}" | cut -d ":" -f2 | cut -d "," -f1 | sed 's/^.\(.*\).$/\1/')
|
||||
export _H1="Authorization: Bearer $authToken"
|
||||
_info "Successfully acquired AUTH-Token"
|
||||
_debug "AUTH-Token: '${authToken}'"
|
||||
_debug "_H1 '${_H1}'"
|
||||
else
|
||||
_err "Couldn't acquire an AUTH-Token"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Commit changes
|
||||
_cn_commit() {
|
||||
_info "Commiting changes"
|
||||
_post "" "${CN_API}/dnszones/$h/records/commit"
|
||||
}
|
||||
|
||||
_cn_get_root() {
|
||||
domain=$1
|
||||
i=2
|
||||
p=1
|
||||
while true; do
|
||||
|
||||
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
|
||||
_debug h "$h"
|
||||
_debug _H1 "${_H1}"
|
||||
|
||||
if [ -z "$h" ]; then
|
||||
#not valid
|
||||
return 1
|
||||
fi
|
||||
|
||||
_cn_zonelist="$(_get ${CN_API}/dnszones/)"
|
||||
_debug _cn_zonelist "${_cn_zonelist}"
|
||||
|
||||
if [ "$?" != "0" ]; then
|
||||
_err "something went wrong while getting the zone list"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if _contains "$_cn_zonelist" "\"name\":\"$h\"" >/dev/null; then
|
||||
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
|
||||
_domain=$h
|
||||
return 0
|
||||
else
|
||||
_debug "Zonelist does not contain domain - iterating "
|
||||
fi
|
||||
p=$i
|
||||
i=$(_math "$i" + 1)
|
||||
|
||||
done
|
||||
_err "Zonelist does not contain domain - exiting"
|
||||
return 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user