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 协议》,转载必须注明作者和本文链接
推荐使用dns-01方式,请参考:
按照步骤来弄的,报这个错误
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')],)",),)),这个是什么原因呢