mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2026-08-15 12:50:51 +02:00
Some checks are pending
DNS / CheckToken (push) Waiting to run
DNS / Fail (push) Blocked by required conditions
DNS / Docker (push) Blocked by required conditions
DNS / MacOS (push) Blocked by required conditions
DNS / Windows (push) Blocked by required conditions
DNS / FreeBSD (push) Blocked by required conditions
DNS / GhostBSD (push) Blocked by required conditions
DNS / OpenBSD (push) Blocked by required conditions
DNS / NetBSD (push) Blocked by required conditions
DNS / DragonFlyBSD (push) Blocked by required conditions
DNS / MidnightBSD (push) Blocked by required conditions
DNS / Solaris (push) Blocked by required conditions
DNS / Omnios (push) Blocked by required conditions
DNS / OpenIndiana (push) Blocked by required conditions
DNS / Tribblix (push) Blocked by required conditions
DNS / Haiku (push) Blocked by required conditions
DragonFlyBSD / DragonFlyBSD (, , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
FreeBSD / FreeBSD (, , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
FreeBSD / FreeBSD (1, , , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
GhostBSD / GhostBSD (, , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
GhostBSD / GhostBSD (1, , , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
Haiku / Haiku (, , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
Haiku / Haiku (1, , , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
Linux / Linux (almalinux:latest) (push) Waiting to run
Linux / Linux (alpine:latest) (push) Waiting to run
Linux / Linux (archlinux:latest) (push) Waiting to run
Linux / Linux (debian:latest) (push) Waiting to run
Linux / Linux (fedora:latest) (push) Waiting to run
Linux / Linux (gentoo/stage3) (push) Waiting to run
Linux / Linux (kalilinux/kali) (push) Waiting to run
Linux / Linux (opensuse/leap:latest) (push) Waiting to run
Linux / Linux (oraclelinux:8) (push) Waiting to run
Linux / Linux (ubuntu:latest) (push) Waiting to run
MacOS / MacOS (, , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
MidnightBSD / MidnightBSD (, , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
NetBSD / NetBSD (, , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
Omnios / Omnios (, , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
Omnios / Omnios (1, , , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
OpenBSD / OpenBSD (, , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
OpenBSD / OpenBSD (1, , , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
OpenIndiana / OpenIndiana (, , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
OpenIndiana / OpenIndiana (1, , , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
PebbleStrict / PebbleStrict (push) Waiting to run
PebbleStrict / PebbleStrict_IPCert (push) Waiting to run
Solaris / Solaris (, , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
Solaris / Solaris (1, , , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
Tribblix / Tribblix (, , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
Tribblix / Tribblix (1, , , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
Ubuntu / Ubuntu (, , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
Ubuntu / Ubuntu (1, , , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
Ubuntu / Ubuntu (Smallstep Intermediate CA, Smallstep Intermediate CA, , 1, https://localhost:9000/acme/acme/directory, ) (push) Waiting to run
Ubuntu / Ubuntu (Smallstep Intermediate CA, Smallstep Intermediate CA, , 1, https://localhost:9000/acme/acme/directory, 1, , 172.17.0.1) (push) Waiting to run
Ubuntu / Ubuntu (ZeroSSL RSA DV SSL CA 2, ZeroSSL ECC DV SSL CA 2, githubtest@acme.sh, ZeroSSL.com, ) (push) Waiting to run
Windows / Windows (, , , LetsEncrypt.org_test, (STAGING)) (push) Waiting to run
Build DockerHub / CheckToken (push) Waiting to run
Build DockerHub / build (push) Blocked by required conditions
Shellcheck / ShellCheck (push) Waiting to run
Shellcheck / shfmt (push) Waiting to run
This must've been a copy-paste error from `dns_ddnss`.
Fixes: 6b7b5caf54 ("DNS provider API: structured description")
202 lines
5.3 KiB
Bash
202 lines
5.3 KiB
Bash
#!/usr/bin/env sh
|
|
# shellcheck disable=SC2034
|
|
dns_desec_info='deSEC.io
|
|
Site: desec.readthedocs.io/en/latest/
|
|
Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi#dns_desec
|
|
Options:
|
|
DEDYN_TOKEN API Token
|
|
Issues: github.com/acmesh-official/acme.sh/issues/2180
|
|
Author: Zheng Qian
|
|
'
|
|
|
|
REST_API="https://desec.io/api/v1/domains"
|
|
|
|
######## Public functions #####################
|
|
|
|
#Usage: dns_desec_add _acme-challenge.foobar.dedyn.io "d41d8cd98f00b204e9800998ecf8427e"
|
|
dns_desec_add() {
|
|
fulldomain=$1
|
|
txtvalue=$2
|
|
_info "Using desec.io api"
|
|
_debug fulldomain "$fulldomain"
|
|
_debug txtvalue "$txtvalue"
|
|
|
|
DEDYN_TOKEN="${DEDYN_TOKEN:-$(_readaccountconf_mutable DEDYN_TOKEN)}"
|
|
|
|
if [ -z "$DEDYN_TOKEN" ]; then
|
|
DEDYN_TOKEN=""
|
|
_err "You did not specify DEDYN_TOKEN yet."
|
|
_err "Please create your key and try again."
|
|
_err "e.g."
|
|
_err "export DEDYN_TOKEN=d41d8cd98f00b204e9800998ecf8427e"
|
|
return 1
|
|
fi
|
|
#save the api token to the account conf file.
|
|
_saveaccountconf_mutable DEDYN_TOKEN "$DEDYN_TOKEN"
|
|
|
|
_debug "First detect the root zone"
|
|
if ! _get_root "$fulldomain" "$REST_API/"; then
|
|
_err "invalid domain"
|
|
return 1
|
|
fi
|
|
_sub_domain=$(echo "$_sub_domain" | _lower_case)
|
|
_debug _sub_domain "$_sub_domain"
|
|
_debug _domain "$_domain"
|
|
|
|
# Get existing TXT record
|
|
_debug "Getting txt records"
|
|
txtvalues="\"\\\"$txtvalue\\\"\""
|
|
_desec_rest GET "$REST_API/$_domain/rrsets/$_sub_domain/TXT/"
|
|
|
|
if [ "$_code" = "200" ]; then
|
|
oldtxtvalues="$(echo "$response" | _egrep_o "\"records\":\\[\"[^ ]*\"\\]" | cut -d : -f 2 | tr -d "[]\\\\\"" | sed "s/,/ /g")"
|
|
_debug "existing TXT found"
|
|
_debug oldtxtvalues "$oldtxtvalues"
|
|
if [ -n "$oldtxtvalues" ]; then
|
|
for oldtxtvalue in $oldtxtvalues; do
|
|
txtvalues="$txtvalues, \"\\\"$oldtxtvalue\\\"\""
|
|
done
|
|
fi
|
|
fi
|
|
_debug txtvalues "$txtvalues"
|
|
_info "Adding record"
|
|
body="[{\"subname\":\"$_sub_domain\", \"type\":\"TXT\", \"records\":[$txtvalues], \"ttl\":3600}]"
|
|
|
|
if _desec_rest PUT "$REST_API/$_domain/rrsets/" "$body"; then
|
|
if _contains "$response" "$txtvalue"; then
|
|
_info "Added, OK"
|
|
return 0
|
|
else
|
|
_err "Add txt record error."
|
|
return 1
|
|
fi
|
|
fi
|
|
|
|
_err "Add txt record error."
|
|
return 1
|
|
}
|
|
|
|
#Usage: fulldomain txtvalue
|
|
#Remove the txt record after validation.
|
|
dns_desec_rm() {
|
|
fulldomain=$1
|
|
txtvalue=$2
|
|
_info "Using desec.io api"
|
|
_debug fulldomain "$fulldomain"
|
|
_debug txtvalue "$txtvalue"
|
|
|
|
DEDYN_TOKEN="${DEDYN_TOKEN:-$(_readaccountconf_mutable DEDYN_TOKEN)}"
|
|
|
|
if [ -z "$DEDYN_TOKEN" ]; then
|
|
DEDYN_TOKEN=""
|
|
_err "You did not specify DEDYN_TOKEN yet."
|
|
_err "Please create your key and try again."
|
|
_err "e.g."
|
|
_err "export DEDYN_TOKEN=d41d8cd98f00b204e9800998ecf8427e"
|
|
return 1
|
|
fi
|
|
|
|
_debug "First detect the root zone"
|
|
if ! _get_root "$fulldomain" "$REST_API/"; then
|
|
_err "invalid domain"
|
|
return 1
|
|
fi
|
|
_sub_domain=$(echo "$_sub_domain" | _lower_case)
|
|
_debug _sub_domain "$_sub_domain"
|
|
_debug _domain "$_domain"
|
|
|
|
# Get existing TXT record
|
|
_debug "Getting txt records"
|
|
txtvalues=""
|
|
_desec_rest GET "$REST_API/$_domain/rrsets/$_sub_domain/TXT/"
|
|
|
|
if [ "$_code" = "200" ]; then
|
|
oldtxtvalues="$(echo "$response" | _egrep_o "\"records\":\\[\"[^ ]*\"\\]" | cut -d : -f 2 | tr -d "[]\\\\\"" | sed "s/,/ /g")"
|
|
_debug "existing TXT found"
|
|
_debug oldtxtvalues "$oldtxtvalues"
|
|
if [ -n "$oldtxtvalues" ]; then
|
|
for oldtxtvalue in $oldtxtvalues; do
|
|
if [ "$txtvalue" != "$oldtxtvalue" ]; then
|
|
txtvalues="$txtvalues, \"\\\"$oldtxtvalue\\\"\""
|
|
fi
|
|
done
|
|
fi
|
|
fi
|
|
txtvalues="$(echo "$txtvalues" | cut -c3-)"
|
|
_debug txtvalues "$txtvalues"
|
|
|
|
_info "Deleting record"
|
|
body="[{\"subname\":\"$_sub_domain\", \"type\":\"TXT\", \"records\":[$txtvalues], \"ttl\":3600}]"
|
|
_desec_rest PUT "$REST_API/$_domain/rrsets/" "$body"
|
|
if [ "$_code" = "200" ]; then
|
|
_info "Deleted, OK"
|
|
return 0
|
|
fi
|
|
|
|
_err "Delete txt record error."
|
|
return 1
|
|
}
|
|
|
|
#################### Private functions below ##################################
|
|
|
|
_desec_rest() {
|
|
m="$1"
|
|
ep="$2"
|
|
data="$3"
|
|
|
|
export _H1="Authorization: Token $DEDYN_TOKEN"
|
|
export _H2="Accept: application/json"
|
|
export _H3="Content-Type: application/json"
|
|
|
|
if [ "$m" != "GET" ]; then
|
|
_secure_debug2 data "$data"
|
|
response="$(_post "$data" "$ep" "" "$m")"
|
|
_info "Sleeping 1s to respect deSEC write rate limit"
|
|
_sleep 1
|
|
else
|
|
response="$(_get "$ep")"
|
|
fi
|
|
_ret="$?"
|
|
_code="$(grep "^HTTP" "$HTTP_HEADER" | _tail_n 1 | cut -d " " -f 2 | tr -d "\\r\\n")"
|
|
_debug "http response code $_code"
|
|
_secure_debug2 response "$response"
|
|
if [ "$_ret" != "0" ]; then
|
|
_err "error $ep"
|
|
return 1
|
|
fi
|
|
|
|
response="$(printf "%s" "$response" | _normalizeJson)"
|
|
return 0
|
|
}
|
|
|
|
#_acme-challenge.www.domain.com
|
|
#returns
|
|
# _sub_domain=_acme-challenge.www
|
|
# _domain=domain.com
|
|
_get_root() {
|
|
domain="$1"
|
|
ep="$2"
|
|
i=2
|
|
p=1
|
|
while true; do
|
|
h=$(printf "%s" "$domain" | cut -d . -f "$i"-100)
|
|
_debug h "$h"
|
|
if [ -z "$h" ]; then
|
|
#not valid
|
|
return 1
|
|
fi
|
|
|
|
if ! _desec_rest GET "$ep"; then
|
|
return 1
|
|
fi
|
|
|
|
if _contains "$response" "\"name\":\"$h\"" >/dev/null; then
|
|
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-"$p")
|
|
_domain=$h
|
|
return 0
|
|
fi
|
|
p=$i
|
|
i=$(_math "$i" + 1)
|
|
done
|
|
return 1
|
|
}
|