利用certbot-auto生成证书

安装Certbot-auto

cd /mnt/runtime
mkdir certbot-auto
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto

生成证书

./certbot-auto certonly -d *.domain.com --manual --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory

登录域名控制台,按提示添加txt记录,验证域名所有权

添加完成后,可进行本地检测:

nslookup -q=txt _acme-challenge.domain.com

查看返回结果与要求的值是否一致,如果一致,则继续操作。

最后生成的证书文件存放在:/etc/letsencrypt/live/域名目录下。

手动续期证书

./certbot-auto renew --force-renew

续期证书计划任务

crontab -e
0 2 1 * * /mnt/runtime/certbot-auto/certbot-auto renew --no-self-upgrade --renew-hook "nginx -s reload"
crontab -l

即每月1日凌晨2点自动运行续期任务。

常见问题

renew时提示:OCSP check failed for /etc/letsencrypt/archive/domain.com/cert1.pem (are we offline?)

原因是OCSP服务的域名DNS无法正常访问,可以修改本地/etc/hosts文件,手动增加一条解析:
23.32.3.72 ocsp.int-x3.letsencrypt.org
修改完成后,无需重启服务,再次renew即可

renew时提示:The manual plugin is not working

红色字体的:PluginError('An authentication script must be provided with --manual-auth-hook when using the manual plugin non-interactively.',)
原因是未明确提供域名的验证方式(--manual-auth-hook)
可以重新执行生成证书的命令,到时候会提示证书已存在,选择是保存现状,还是进行更新,选择更新即可重新通过DNS TXT记录的方式进行验证并且更新证书。

posted @ 2020-10-01 21:48  网无忌  阅读(774)  评论(0编辑  收藏  举报