acme.sh 在使用中后续增加域名等维护操作
发布时间:2025-03-03
浏览量: 955
文章分类: 运维相关
acme.sh 在使用中后续增加域名等维护操作
我们在使用acme.sh进行自动管理https证书更新后,比如过了一段时间需要新增域名或移除域名时,
查看目前的维护列表
acme.sh --list 这个命令可以查看到目前申请的证书,以及每个证书的状态信息。
提示信息如下,会把所有的都列出来。
root:/home/***# acme.sh --list
Main_Domain KeyLength SAN_Domains CA Created Renew
***.com "ec-256" *.***.com ZeroSSL.com 2025-01-22T13:29:30Z 2025-03-22T13:29:30Z
***.com "ec-256" *.***.com ZeroSSL.com 2025-01-23T13:29:12Z 2025-03-23T13:29:12Z
如果想查看某个特定域名的证书详情也可以使用 acme.sh --info -d yuming.com 来查看。
查看后会有更加详细的信息输出,敏感信息我替换成***了
root:/home/***# acme.sh --info -d ***.com
[Mon Mar 3 02:08:21 AM CST 2025] The domain '***.com' seems to already have an ECC cert, let's use it.
DOMAIN_CONF=/root/.acme.sh/***.com_ecc/***.com.conf
Le_Domain=***.com
Le_Alt=*.***.com
Le_Webroot=dns_ali
Le_PreHook=
Le_PostHook=
Le_RenewHook=
Le_API=https://acme.zer***
Le_Keylength=ec-256
Le_OrderFinalize=https://acme.zerossl.com/v2/DV90/order/M***
Le_LinkOrder=https://acme.zerossl.com/v2/DV90/order/MKYiq20nk***
Le_LinkCert=https://acme.zerossl.com/v2/DV90/cert/W-efhS6hKt***
Le_CertCreateTime=1737552570
Le_CertCreateTimeStr=2025-01-22T13:29:30Z
Le_NextRenewTimeStr=2025-03-22T13:29:30Z
Le_NextRenewTime=174265***
Le_RealCertPath=/home/***/cert/***.com.crt
Le_RealCACertPath=/home/***/cert/ca.cer
Le_RealKeyPath=/home/***/cert/***.com.key
Le_ReloadCmd=
Le_RealFullChainPath=/home/***/cert/***.cer
上面的信息基本把整个域名的情况都进行了输出,实际可以在自己的电脑上操作试试。
更新acme.sh至最新状态
不论你设置了自动更新还是没有设置,在执行操作前,最好都先执行一下这个命令acme.sh --upgrade
执行后会有如下提示
root:/home/***# acme.sh --upgrade
[Mon Mar 3 03:05:04 AM CST 2025] Installing from online archive.
[Mon Mar 3 03:05:04 AM CST 2025] Downloading https://github.com/acmesh-official/acme.sh/archive/master.tar.gz
[Mon Mar 3 03:05:06 AM CST 2025] Extracting master.tar.gz
[Mon Mar 3 03:05:06 AM CST 2025] It is recommended to install socat first.
[Mon Mar 3 03:05:06 AM CST 2025] We use socat for the standalone server, which is used for standalone mode.
[Mon Mar 3 03:05:06 AM CST 2025] If you don't want to use standalone mode, you may ignore this warning.
[Mon Mar 3 03:05:06 AM CST 2025] Installing to /root/.acme.sh
[Mon Mar 3 03:05:06 AM CST 2025] Installed to /root/.acme.sh/acme.sh
[Mon Mar 3 03:05:06 AM CST 2025] bash has been found. Changing the shebang to use bash as preferred.
[Mon Mar 3 03:05:07 AM CST 2025] OK
[Mon Mar 3 03:05:07 AM CST 2025] Install success!
[Mon Mar 3 03:05:07 AM CST 2025] Upgrade successful!
申请证书
这个比较简单,和之前我写的文章里面的是一致的。
acme.sh --issue --dns dns_ali -d mingtae.com -d *.mingtae.com
执行后稍微耐心等待成功就可以。具体的可以查看这里使用acme.sh白嫖https证书记录
配置证书
这个就是在申请成功后对证书的简单配置工作了。
acme.sh --installcert -d ***.com --key-file /home/***/cert/www.***.com.key --fullchain-file /home/***/cert/www.***.com.crt --reloadcmd "systemctl force-reload nginx"
执行后会有如下提示则表示成功
[Mon Mar 3 04:35:38 PM CST 2025] The domain '***.com' seems to already have an ECC cert, let's use it.
[Mon Mar 3 04:35:38 PM CST 2025] Installing key to: /home/***/cert/www.***.com.key
[Mon Mar 3 04:35:38 PM CST 2025] Installing full chain to: /home/***/cert/www.***.com.crt
[Mon Mar 3 04:35:38 PM CST 2025] Running reload cmd: systemctl force-reload nginx
[Mon Mar 3 04:35:39 PM CST 2025] Reload successful
后续收尾
现在证书已经申领成功,在对应你设置的目录下也有了对应的证书文件,接下来只是一些在Nginx的配置就已经解决。