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 协议》,转载必须注明作者和本文链接
推荐文章: