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 协议》,转载必须注明作者和本文链接
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《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年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!