使用 acme.sh 管理 Let’s Encrypt Wildcard SSL 证书

Certbot 可以申请 Wildcard 证书,但更新不便,还是推荐使用 acme.sh。

安装

curl https://get.acme.sh | sh

配置 API

编辑 ~/.bashrc ,加入以下内容(以 cloudflare global key 为例):

export CF_Key="123456789"

export CF_Email="a@b.com"

保存后,执行:

source ~/.bashrc

申请证书

acme.sh --issue --dns dns_cf -d ladotech.com -d *.ladotech.com

值得一提的是,如果有多个域名,各自使用不同的 DNS,可以参考以下命令:

acme.sh --issue \
-d ladotech.com --dns dns_cf \
-d *.ladotech.com --dns dns_cf \
-d a.com --dns dns_namecom \
-d *.a.com --dns dns_namecom \
-d b.com --dns dns_dp \
-d *.b.com --dns dns_dp

安装证书

acme.sh --install-cert -d ladotech.com \
--key-file /etc/nginx/certs/ladotech.com.key \
--fullchain-file /etc/nginx/certs/ladotech.com.fullchain.cer \
--reloadcmd "systemctl force-reload nginx"

一切配置妥当后,开启 acme.sh 的自动版本更新:

acme.sh --upgrade --auto-upgrade