From 069735d3b04694753b22b07dd79a14a37fe6c8a6 Mon Sep 17 00:00:00 2001 From: Preston Goforth <preston.goforth@gmail.com> Date: Sat, 1 Feb 2025 17:08:39 -0500 Subject: [PATCH] Fix cPanel scripts to handle wild card domains and use correct API parameters --- dns_scripts/dns_add_cpanel | 4 ++-- dns_scripts/dns_del_cpanel | 2 +- getssl | 3 ++- other_scripts/cpanel_cert_upload | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dns_scripts/dns_add_cpanel b/dns_scripts/dns_add_cpanel index 24a1ca8a..ed3bd922 100755 --- a/dns_scripts/dns_add_cpanel +++ b/dns_scripts/dns_add_cpanel @@ -61,11 +61,11 @@ fi # If no existing record, create a new TXT record, otherwise edit the existing record if [[ "$resp" == *\"data\":[]* ]]; then - request_params="&cpanel_jsonapi_func=add_zone_record&domain=$domain&type=TXT&name=_acme-challenge$name&txtdata=$token" + request_params="&cpanel_jsonapi_func=add_zone_record&domain=${domain}&type=TXT&name=_acme-challenge&txtdata=${token}" else # shellcheck disable=SC2001 line=$(echo "$resp" | sed -e 's/.*line":\([0-9]*\),.*/\1/') - request_params="&cpanel_jsonapi_func=edit_zone_record&domain=$domain&type=TXT&name=_acme-challenge$name&txtdata=${token}&line=${line}" + request_params="&cpanel_jsonapi_func=edit_zone_record&domain=${domain}&type=TXT&name=_acme-challenge&txtdata=${token}&line=${line}" fi resp=$(curl --silent "${curl_params[@]}" "$request_func$request_params") diff --git a/dns_scripts/dns_del_cpanel b/dns_scripts/dns_del_cpanel index 922151a5..10bb7a06 100755 --- a/dns_scripts/dns_del_cpanel +++ b/dns_scripts/dns_del_cpanel @@ -58,7 +58,7 @@ fi line=$(echo "$resp" | sed -e 's/.*line":\([0-9]*\),.*/\1/') if [[ "$line" != "" ]]; then # Delete the challenge token - request_params="&cpanel_jsonapi_func=remove_zone_record&domain=$domain&type=TXT&name=_acme-challenge$name&line=$line" + request_params="&cpanel_jsonapi_func=remove_zone_record&domain=${domain}&type=TXT&name=_acme-challenge&line=${line}" resp=$(curl --silent "${curl_params[@]}" "$request_func$request_params") fi diff --git a/getssl b/getssl index d762666e..cc64a3f6 100755 --- a/getssl +++ b/getssl @@ -292,6 +292,7 @@ # 2024-03-18 Refresh the TXT record if a CNAME is found (JoergBruce #828) (2.49) # 2024-03-26 Test for "true" in wildcard property of authorization responses # 2024-10-16 Add newlines to /directory response (#765)(#859) +# 2025-02-02 Fix cPanel support for API zone record updates and wildcard domain support # ---------------------------------------------------------------------------------------- case :$SHELLOPTS: in @@ -300,7 +301,7 @@ esac PROGNAME=${0##*/} PROGDIR="$(cd "$(dirname "$0")" || exit; pwd -P;)" -VERSION="2.49" +VERSION="2.50" # defaults ACCOUNT_KEY_LENGTH=4096 diff --git a/other_scripts/cpanel_cert_upload b/other_scripts/cpanel_cert_upload index 1a937579..982c822b 100755 --- a/other_scripts/cpanel_cert_upload +++ b/other_scripts/cpanel_cert_upload @@ -5,6 +5,7 @@ # use with RELOAD_CMD="${HOME}/cpanel_cert_upload domain.com" domain="$1" +nowild=$(echo "${1//\*\./}") rawurlencode() { local string @@ -28,4 +29,4 @@ ecert=$( rawurlencode "${HOME}/.getssl/${domain}/${domain}.crt" ) ekey=$( rawurlencode "${HOME}/.getssl/${domain}/${domain}.key" ) echain=$( rawurlencode "${HOME}/.getssl/${domain}/chain.crt" ) -uapi SSL install_ssl domain="${domain}" cert="${ecert}" key="${ekey}" cabundle="${echain}" +uapi SSL install_ssl domain="${nowild}" cert="${ecert}" key="${ekey}" cabundle="${echain}"