这篇文章上次修改于 815 天前,可能其部分内容已经发生变化,如有疑问可询问作者。

今早发现 paugram.com 的 SSL 证书到期,郁闷的是为什么没有自动进行签发,查询了一下,是我的 acme.sh 脚本执行出了点问题。

21.12.05 更新:前段时间重装了一次服务器环境,确认了下重装环境下的配置也确实是这样子编写,没问题的,可放心食用~

折腾过程

服务器是 OneInstack 搭建的环境,acme.sh 脚本默认放置在 /root/.acme.sh 目录下。

cd /root/.acme.sh

我试了下手动执行签发命令,一直在反复重试,没有成功提示。

/root/.acme.sh/acme.sh --cron --home /root/.acme.sh

[2021年 07月 30日 星期五 12:53:50 CST] Renew: 'paugram.com'
[2021年 07月 30日 星期五 12:53:51 CST] Sleep 10 and retry.

根据网上的帖子,试了下手动更新指定域名的命令,并打印 Debug 详情数据:

acme.sh --list
acme.sh --renew -d paugram.com --server letsencrypt3 --debug 2

Debug 信息打印出来之后,得知是 API 返回错误,看说明是使用的服务器为 V1,已经过期需要更新。

[2021年 07月 30日 星期五 12:18:38 CST] response='{
  "type": "urn:acme:error:serverInternal",
  "detail": "ACMEv1 is deprecated and you can no longer get certificates from this endpoint. Please use the ACMEv2 endpoint, you may need to update your ACME client software to do so. Visit https://community.letsencrypt.org/t/end-of-life-plan-for-acmev1/88430/27 for more information."
}'

我先是使用 OneInstack 的升级脚本升级了 acme.sh

~/oneinstack/upgrade.sh

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 8+ and Ubuntu 16+      #
#              Upgrade Software versions for OneinStack               #
#       For more information please visit https://oneinstack.com      #
#######################################################################

What Are You Doing?
     1. Upgrade Nginx/Tengine/OpenResty
     2. Upgrade Apache
     3. Upgrade Tomcat
     4. Upgrade MySQL/MariaDB/Percona
     5. Upgrade PHP
     6. Upgrade Redis
     7. Upgrade Memcached
     8. Upgrade phpMyAdmin
     9. Upgrade OneinStack latest
    10. Upgrade acme.sh latest
     q. Exit

Please input the correct option: 10

升级结束,检查了 acme.sh 已经是 3.0 最新版,重新执行 renew 命令,依旧是用了旧的 API。

解决方法

看了下别人的帖子说是要检查一下站点里面的 conf 文件,果不其然这里用了 V1 服务器。但是帖子里并没有具体说明怎么修改,而我自己随手试了下,只要把里面的 v01 替换成 v02,输入 :wq 保存之后,重新执行 renew 命令即可解决。

vim paugram.com/paugram.com.conf
Le_Domain='paugram.com'
Le_Alt='no'
Le_Webroot='/data/wwwroot/paugram.com'
Le_PreHook=''
Le_PostHook=''
Le_RenewHook=''
Le_API='https://acme-v01.api.letsencrypt.org/directory'
Le_Keylength=''
Le_LinkCert='https://acme-v01.api.letsencrypt.org/acme/cert/xxxxx'
Le_LinkIssuer='https://acme-v01.api.letsencrypt.org/acme/issuer-cert'

重新执行 Cron 那条命令,可以看到域名可以成功签发了

[2021年 07月 30日 星期五 12:56:10 CST] Verifying: paugram.com
[2021年 07月 30日 星期五 12:56:11 CST] Pending, The CA is processing your order, please just wait. (1/30)
[2021年 07月 30日 星期五 12:56:13 CST] Success
[2021年 07月 30日 星期五 12:56:13 CST] Verify finished, start to sign.
[2021年 07月 30日 星期五 12:56:13 CST] Lets finalize the order.

参考资料

Your ACME client has the ACMEv1 webroot as the directory endpoint in some of your renewal configuration files. Change those to the ACMEv2 directory endpoint and you should be fine.

-- Griffin