openwrt / openwrt/packages

acme dns_duckdb error extracting the domain

Open
#25,933 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Makefile
Stars
4.6k
Forks
4k
Avg merge
3d 12h
Merged PRs (30d)
134

Description

Hi,

Can't renew certificate through DNS API.

To reproduce:

# export DuckDNS_Token="184b69af-5862-410f-be2b-883f0743b8f9"
# /usr/lib/acme/client/acme.sh --test --renew --home /etc/acme --domain test.duckdns.org
[Mon Feb 10 19:03:02 +07 2025] Using ACME_DIRECTORY: https://acme-staging-v02.api.letsencrypt.org/directory
[Mon Feb 10 19:03:02 +07 2025] Renew: 'test.duckdns.org'
[Mon Feb 10 19:03:02 +07 2025] Renew to Le_API=https://acme-v02.api.letsencrypt.org/directory
[Mon Feb 10 19:03:03 +07 2025] Using CA: https://acme-v02.api.letsencrypt.org/directory
[Mon Feb 10 19:03:04 +07 2025] Single domain='test.duckdns.org'
[Mon Feb 10 19:03:04 +07 2025] Getting domain auth token for each domain
[Mon Feb 10 19:03:07 +07 2025] Getting webroot for domain='test.duckdns.org'
[Mon Feb 10 19:03:07 +07 2025] Adding txt value: EQbV2_zKJf9C0oiqnUcdSqUOLLhjjoRRzs0ygLaVPFQ for domain:  _acme-challenge.test.duckdns.org
[Mon Feb 10 19:03:07 +07 2025] Error extracting the domain.
[Mon Feb 10 19:03:07 +07 2025] Error add txt for domain:_acme-challenge.test.duckdns.org
[Mon Feb 10 19:03:07 +07 2025] Please check log file for more details: /tmp/acme.log

Error raised from this: /usr/lib/acme/client/dnsapi/dns_duckdns.sh
dns_duckdns_add => _duckdns_get_domain => _egrep_o

_egrep_o seems uses sed which works incorrect with this regular expression. As result _duckdns_domain is always empty.

Source code links:

OS info:

# cat /etc/os-release 
NAME="OpenWrt"
VERSION="24.10.0"
ID="openwrt"
ID_LIKE="lede openwrt"
PRETTY_NAME="OpenWrt 24.10.0"
VERSION_ID="24.10.0"
HOME_URL="https://openwrt.org/"
BUG_URL="https://bugs.openwrt.org/"
SUPPORT_URL="https://forum.openwrt.org/"
BUILD_ID="r28427-6df0e3d02a"
OPENWRT_BOARD="mediatek/filogic"
OPENWRT_ARCH="aarch64_cortex-a53"
OPENWRT_TAINTS=""
OPENWRT_DEVICE_MANUFACTURER="OpenWrt"
OPENWRT_DEVICE_MANUFACTURER_URL="https://openwrt.org/"
OPENWRT_DEVICE_PRODUCT="Generic"
OPENWRT_DEVICE_REVISION="v0"
OPENWRT_RELEASE="OpenWrt 24.10.0 r28427-6df0e3d02a"
OPENWRT_BUILD_DATE="1738624177"

# opkg list-installed | grep acme
acme - 4.0.0
acme-acmesh - 3.0.7-r2
acme-acmesh-dnsapi - 3.0.7-r2
acme-common - 1.4.0
luci-app-acme - 25.037.68331~42f464c

Also tried with this code:

if [ "$(echo abc | egrep -o b 2>/dev/null)" = "b" ]; then
  __USE_EGREP=1
else
  __USE_EGREP=""
fi

_egrep_o() {
  if [ "$__USE_EGREP" ]; then
    egrep -o -- "$1" 2>/dev/null
  else
    sed -n 's/.*\('"$1"'\).*/\1/p'
  fi
}

_lower_case() {
  # shellcheck disable=SC2018,SC2019
  tr '[A-Z]' '[a-z]'
}

fulldomain="_acme-challenge.test.duckdns.org"

_duckdns_domain="$(printf "%s" "$fulldomain" | _lower_case | _egrep_o '^(_acme-challenge\.)?([a-z0-9-]+\.)+duckdns\.org' | sed -n 's/^\([^.]\{1,\}\.\)*\([a-z0-9-]\{1,\}\)\.duckdns\.org$/\2/p;')"

echo "$__USE_EGREP"
echo "$fulldomain"
echo "$_duckdns_domain"

__USE_EGREP and _duckdns_domain is empty

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with dnsapi/dns_duckdns.sh and the _egrep_o implementation around acme.sh lines 929 and 936. Reproduce the OpenWrt command and the standalone _duckdns_domain example, then verify that domain extraction succeeds and the renewal can add the TXT record for _acme-challenge.test.duckdns.org.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.