177

解决 acme.sh 自动签发 Let's Encrypt 证书失效

 2 years ago
source link: https://paugram.com/tech/acme-sh-upgrade-lets-encrypt-v1-to-v2.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

解决 acme.sh 自动签发 Let's Encrypt 证书失效

2021.07.30做个技术宅 3 191

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

服务器是 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

Paul

特立独行的一只前端菜狗。本站未注明转载的文章均为原创,并采用 CC BY-NC-SA 4.0 授权协议,转载请注明来源,谢谢!如本站内容对你有所帮助的话,不妨 捐助支持 一下?同时欢迎订阅关注 我的日记,唠嗑(分享)每日的折腾经历。

已有 3 条评论

g?b=qq&nk=3489996586&s=100
小小小明 2 天前

能否给此主题加入无刷刷新呢?除了这一点简直完美.

Paul

@小小小明 Single 主题暂时不考虑增加 PJAX

g?b=qq&nk=3550450738&s=100
马内 3 天前

技术文章,学习了。
80% WordPress/Typecho,都是在讲前端开发


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK