mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2026-08-13 12:33:30 +02:00
Some checks are pending
Apache / Apache (push) Waiting to run
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
Nginx / Nginx (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
dnsapi/deploy: remove POSIX character classes from sed/grep patterns Solaris /usr/bin/sed and /usr/bin/grep parse [[:space:]] etc. as a literal bracket set and silently mis-match. Replace with [ ]* for JSON matching, a printf-tab bracket for user-input trimming, and [0-9] for digits; also drop GNU-only sed -r/-E in rage4, selfhost and selectel, and reuse _strip_blank_lines in byteplus_alb.
204 lines
5.6 KiB
Bash
204 lines
5.6 KiB
Bash
#!/usr/bin/env sh
|
|
|
|
# dns_czechia.sh - CZECHIA.COM/ZONER DNS API for acme.sh (DNS-01)
|
|
#
|
|
# Documentation: https://api.czechia.com/swagger/index.html
|
|
|
|
#shellcheck disable=SC2034
|
|
dns_czechia_info='[
|
|
{"name":"CZ_AuthorizationToken","usage":"Your API token from CZECHIA.COM/Zoner administration.","required":"1"},
|
|
{"name":"CZ_Zones","usage":"Managed zones separated by comma or space (e.g. \"example.com\").","required":"1"},
|
|
{"name":"CZ_API_BASE","usage":"Defaults to https://api.czechia.com","required":"0"}
|
|
]'
|
|
|
|
dns_czechia_add() {
|
|
fulldomain="$1"
|
|
txtvalue="$2"
|
|
|
|
_debug "dns_czechia_add fulldomain='$fulldomain'"
|
|
|
|
if [ -z "$fulldomain" ] || [ -z "$txtvalue" ]; then
|
|
_err "dns_czechia_add: missing fulldomain or txtvalue"
|
|
return 1
|
|
fi
|
|
|
|
_czechia_load_conf || return 1
|
|
|
|
_current_zone=$(_czechia_pick_zone "$fulldomain")
|
|
if [ -z "$_current_zone" ]; then
|
|
_err "No matching zone found for $fulldomain. Please check CZ_Zones."
|
|
return 1
|
|
fi
|
|
|
|
_czechia_tab="$(printf '\t')"
|
|
_cz=$(printf "%s" "$_current_zone" | _lower_case | sed "s/[ $_czechia_tab]//g; s/\.\$//")
|
|
_tk=$(printf "%s" "$CZ_AuthorizationToken" | sed "s/^[ $_czechia_tab]*//; s/[ $_czechia_tab]*\$//")
|
|
|
|
if [ -z "$_cz" ] || [ -z "$_tk" ]; then
|
|
_err "Missing zone or CZ_AuthorizationToken."
|
|
return 1
|
|
fi
|
|
|
|
_url="$CZ_API_BASE/api/DNS/$_cz/TXT"
|
|
_fd=$(printf "%s" "$fulldomain" | _lower_case | sed 's/\.$//')
|
|
|
|
if [ "$_fd" = "$_cz" ]; then
|
|
_h="@"
|
|
else
|
|
# Remove the literal ".<zone>" suffix from _fd, if present
|
|
_h=${_fd%."$_cz"}
|
|
[ "$_h" = "$_fd" ] && _h="@"
|
|
fi
|
|
[ -z "$_h" ] && _h="@"
|
|
|
|
_info "Adding TXT record for $_h in zone $_cz"
|
|
|
|
_h_esc=$(printf "%s" "$_h" | sed 's/\\/\\\\/g; s/"/\\"/g')
|
|
_txt_esc=$(printf "%s" "$txtvalue" | sed 's/\\/\\\\/g; s/"/\\"/g')
|
|
_body="{\"hostName\":\"$_h_esc\",\"text\":\"$_txt_esc\",\"ttl\":300,\"publishZone\":1}"
|
|
|
|
_debug "URL: $_url"
|
|
_debug "Body: $_body"
|
|
|
|
export _H1="Content-Type: application/json"
|
|
export _H2="AuthorizationToken: $_tk"
|
|
|
|
_res="$(_post "$_body" "$_url" "" "POST")"
|
|
_post_exit="$?"
|
|
_debug2 "Response: $_res"
|
|
|
|
if [ "$_post_exit" -ne 0 ]; then
|
|
_err "API request failed. exit code $_post_exit"
|
|
return 1
|
|
fi
|
|
|
|
if _contains "$_res" "already exists"; then
|
|
_info "Record already exists, skipping."
|
|
return 0
|
|
fi
|
|
|
|
_nres="$(printf '%s' "$_res" | _normalizeJson)"
|
|
if [ "$?" -ne 0 ] || [ -z "$_nres" ]; then
|
|
_nres="$_res"
|
|
fi
|
|
|
|
if _contains "$_nres" "\"status\":4" || _contains "$_nres" "\"status\":5" || _contains "$_nres" "\"errors\""; then
|
|
_err "API error: $_res"
|
|
return 1
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
dns_czechia_rm() {
|
|
fulldomain="$1"
|
|
txtvalue="$2"
|
|
|
|
_debug "dns_czechia_rm fulldomain='$fulldomain'"
|
|
|
|
if [ -z "$fulldomain" ] || [ -z "$txtvalue" ]; then
|
|
_err "dns_czechia_rm: missing fulldomain or txtvalue"
|
|
return 1
|
|
fi
|
|
|
|
_czechia_load_conf || return 1
|
|
|
|
_current_zone=$(_czechia_pick_zone "$fulldomain")
|
|
if [ -z "$_current_zone" ]; then
|
|
_err "No matching zone found for $fulldomain. Please check CZ_Zones configuration."
|
|
return 1
|
|
fi
|
|
|
|
_czechia_tab="$(printf '\t')"
|
|
_cz=$(printf "%s" "$_current_zone" | _lower_case | sed "s/[ $_czechia_tab]//g; s/\.\$//")
|
|
_tk=$(printf "%s" "$CZ_AuthorizationToken" | sed "s/^[ $_czechia_tab]*//; s/[ $_czechia_tab]*\$//")
|
|
|
|
if [ -z "$_cz" ] || [ -z "$_tk" ]; then
|
|
_err "Missing zone or CZ_AuthorizationToken."
|
|
return 1
|
|
fi
|
|
|
|
_url="$CZ_API_BASE/api/DNS/$_cz/TXT"
|
|
_fd=$(printf "%s" "$fulldomain" | _lower_case | sed 's/\.$//')
|
|
|
|
if [ "$_fd" = "$_cz" ]; then
|
|
_h="@"
|
|
else
|
|
_h=$(printf "%s" "$_fd" | sed "s/\.$_cz$//")
|
|
[ "$_h" = "$_fd" ] && _h="@"
|
|
fi
|
|
[ -z "$_h" ] && _h="@"
|
|
|
|
_h_esc=$(printf "%s" "$_h" | sed 's/\\/\\\\/g; s/"/\\"/g')
|
|
_txt_esc=$(printf "%s" "$txtvalue" | sed 's/\\/\\\\/g; s/"/\\"/g')
|
|
_body="{\"hostName\":\"$_h_esc\",\"text\":\"$_txt_esc\",\"ttl\":300,\"publishZone\":1}"
|
|
|
|
_debug "URL: $_url"
|
|
_debug "Body: $_body"
|
|
|
|
export _H1="Content-Type: application/json"
|
|
export _H2="AuthorizationToken: $_tk"
|
|
|
|
_res="$(_post "$_body" "$_url" "" "DELETE")"
|
|
_post_exit="$?"
|
|
_debug2 "Response: $_res"
|
|
|
|
if [ "$_post_exit" -ne 0 ]; then
|
|
_err "CZECHIA DNS API DELETE request failed for $_fd: exit code $_post_exit, response: $_res"
|
|
return 1
|
|
fi
|
|
|
|
_res_normalized=$(printf '%s' "$_res" | _normalizeJson)
|
|
|
|
if _contains "$_res_normalized" '"isError":true'; then
|
|
_err "CZECHIA DNS API reported an error while deleting TXT for $_fd: $_res"
|
|
return 1
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
_czechia_load_conf() {
|
|
CZ_AuthorizationToken="${CZ_AuthorizationToken:-$(_readaccountconf_mutable CZ_AuthorizationToken)}"
|
|
if [ -z "$CZ_AuthorizationToken" ]; then
|
|
_err "Missing CZ_AuthorizationToken"
|
|
return 1
|
|
fi
|
|
|
|
CZ_Zones="${CZ_Zones:-$(_readaccountconf_mutable CZ_Zones)}"
|
|
if [ -z "$CZ_Zones" ]; then
|
|
_err "Missing CZ_Zones"
|
|
return 1
|
|
fi
|
|
|
|
CZ_API_BASE="${CZ_API_BASE:-$(_readaccountconf_mutable CZ_API_BASE)}"
|
|
[ -z "$CZ_API_BASE" ] && CZ_API_BASE="https://api.czechia.com"
|
|
|
|
_saveaccountconf_mutable CZ_AuthorizationToken "$CZ_AuthorizationToken"
|
|
_saveaccountconf_mutable CZ_Zones "$CZ_Zones"
|
|
_saveaccountconf_mutable CZ_API_BASE "$CZ_API_BASE"
|
|
|
|
return 0
|
|
}
|
|
|
|
_czechia_pick_zone() {
|
|
_czechia_pz_tab="$(printf '\t')"
|
|
_fd=$(printf "%s" "$1" | _lower_case | sed 's/\.$//')
|
|
_best_zone=""
|
|
|
|
_zones_space=$(printf "%s" "$CZ_Zones" | sed 's/,/ /g')
|
|
for _z in $_zones_space; do
|
|
_clean_z=$(printf "%s" "$_z" | _lower_case | sed "s/[ $_czechia_pz_tab]//g; s/\.\$//")
|
|
[ -z "$_clean_z" ] && continue
|
|
|
|
case "$_fd" in
|
|
"$_clean_z" | *."$_clean_z")
|
|
if [ ${#_clean_z} -gt ${#_best_zone} ]; then
|
|
_best_zone="$_clean_z"
|
|
fi
|
|
;;
|
|
esac
|
|
done
|
|
|
|
printf "%s" "$_best_zone"
|
|
}
|