264 字
1 分钟
Configuring SSL Certificates with acme.sh on OpenWRT

Preface#

OpenWRT’s built-in luci-app-acme is very hard to use, and official documentation is hard to find (many luci plugins are like this mess, e.g. tinyproxy is also unmaintained…). So I chose the official original acmesh instead.

You can refer to the official README if needed

Installing acme.sh#

Terminal window
wget -O - https://get.acme.sh | sh -s email=my@example.com
cd ~/.acme.sh
./acme.sh --upgrade --auto-upgrade

Configuring DNS API Keys#

Edit the ~/.acme.sh/account.conf file and add the following:

Since I use Cloudflare DNS, if you use something else, please refer to the official docs.

Terminal window
export CF_Zone_ID="aaaaaaaaaaa"
export CF_Token="aaaaaaaa"

Requesting a Certificate#

Use the following command to request a certificate via Cloudflare’s DNS validation method:

Terminal window
./acme.sh --issue --dns dns_cf -d admin.tski.uk -d '*.example.com' # The DNS method supports requesting wildcard certificates

Viewing the Certificate List#

You can view the requested certificates with the following command:

Terminal window
./acme.sh --list

Installing the Certificate#

Install the requested certificate to the target location and restart the uhttpd service:

Terminal window
./acme.sh --install-cert -d admin.tski.uk \
--key-file /etc/uhttpd.key \
--fullchain-file /etc/uhttpd.crt \
--reloadcmd '/etc/init.d/uhttpd restart'

Verifying the Installation Works#

Use the following command to force-renew the certificate:

Terminal window
./acme.sh --renew -d admin.tski.uk --force

If the installation succeeded, the output looks like this:

Terminal window
.......
[Mon Feb 3 16:14:16 CST 2025] Your cert is in: /root/.acme.sh/admin.tski.uk_ecc/admin.tski.uk.cer
[Mon Feb 3 16:14:16 CST 2025] Your cert key is in: /root/.acme.sh/admin.tski.uk_ecc/admin.tski.uk.key
[Mon Feb 3 16:14:16 CST 2025] The intermediate CA cert is in: /root/.acme.sh/admin.tski.uk_ecc/ca.cer
[Mon Feb 3 16:14:16 CST 2025] And the full-chain cert is in: /root/.acme.sh/admin.tski.uk_ecc/fullchain.cer
[Mon Feb 3 16:14:17 CST 2025] Installing key to: /etc/uhttpd.key
[Mon Feb 3 16:14:17 CST 2025] Installing full chain to: /etc/uhttpd.crt
[Mon Feb 3 16:14:17 CST 2025] Running reload cmd: /etc/init.d/uhttpd restart
[Mon Feb 3 16:14:17 CST 2025] Reload successful
Configuring SSL Certificates with acme.sh on OpenWRT
https://tski.uk/blog/en/openwrt-acmesh/
作者
Tokisaki Galaxy
发布于
2025-02-03
许可协议
CC BY