Certbot 申请的 https 证书续期报错的解决方案

之前用 Certbot 申请了 Let's Encrypt 的免费 ssl 证书,前几天邮件提醒快到期了,可我明明记得加了定时任务去自动续期。
于是去看了下日志,发现执行 certbot renew 的时候报错了,手动执行也是同样的报错,大致错误如下:

Could not choose appropriate plugin: The manual plugin is not working; there may be problems with your existing configuration. The error was: PluginError('An authentication script must be provided with --manual-auth-hook when using the manual plugin non-interactively.',). Skipping.

搜索后得知是因为验证域名所有者失败,没有指定 --manual-auth-hook 参数。
Let's Encrypt 有多种验证方式,常用的有 http 和 dns 方式,由于我是在 homestead 虚拟机里面申请的证书,无法使用 http 方式,所以之前申请证书用的是 dns 方式,也就是创建 TXT 记录。
我用的是 DNSPod,便根据 DNSPod 提供的 API 自己写了一个脚本,这里分享给大家。

Certbot DNS Authenticator For DNSPod#

Installing#

$ wget https://raw.githubusercontent.com/al-one/certbot-auth-dnspod/master/certbot-auth-dnspod.sh
$ chmod +x certbot-auth-dnspod.sh

Config#

Get Your DNSPod Token From https://www.dnspod.cn/console/user/securit...

Token Format: ID,Token See: https://www.dnspod.cn/docs/info.html#commo...

$ export DNSPOD_TOKEN="your dnspod token"

or

$ echo "your dnspod token" > /etc/dnspod_token

or

$ echo "your dnspod token" > /etc/dnspod_token_$CERTBOT_DOMAIN
# echo "your dnspod token" > /etc/dnspod_token_laravel.run

Usage#

$ certbot certonly --manual --preferred-challenges dns-01 --email mail@domain.com -d laravel.run -d *.laravel.run --server https://acme-v02.api.letsencrypt.org/directory --manual-auth-hook /path/to/certbot-auth-dnspod.sh

or

$ certbot renew --manual-auth-hook /path/to/certbot-auth-dnspod.sh

or add crontab

0 2 1 * * sh -c 'date "+\%Y-\%m-\%d \%H:\%M:\%S" && /usr/bin/certbot renew --manual-auth-hook /path/to/certbot-auth-dnspod.sh' >> /var/log/certbot-renew.log 2>&1
本作品采用《CC 协议》,转载必须注明作者和本文链接
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 2

按照步骤来弄的,报这个错误
SSLError: HTTPSConnectionPool (host='acme-v02.api.letsencrypt.org', port=443): Max retries exceeded with url: /directory (Caused by SSLError (SSLError ("bad handshake: Error ([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),)),这个是什么原因呢

5年前 评论
Alone (楼主) 5年前
maht (作者) 5年前
Alone (楼主) 5年前
Alone (楼主) 5年前
maht (作者) 5年前
maht (作者) 5年前
Alone (楼主) 5年前
maht (作者) 5年前
Alone (楼主) 5年前
maht (作者) 5年前
Alone (楼主) 5年前
maht (作者) 5年前
maht (作者) 5年前