定期更新Let‘s Encrypt SSL证书遇到的问题
文章目录
- 概要
- 报错信息与解决办法
- 报错信息
- 解决办法
- 方法一:手动更新
- 方法二:自动更新
概要
在文章 用Let‘s Encrypt给网站添加一个免费的SSL证书 中提到了如何手动安装SSL证书,发现到期后通过 crontab 中配置的 certbot renew
更新SSL证书并没有生效,在排查问题的过程中发现有坑,于是再总结一下遇到的问题,给有需要的兄弟参考。
以下实操环境:CentOS 7.9 + Nginx,使用的是云服务器。
报错信息与解决办法
报错信息
Let’s Encrypt安装的SSL证书有90天的有效期,接近过期时需要更新证书,可以通过配置定时任务的方式更新证书,由于我们使用的是–manual方式配置的DNS TXT记录,所以到期后通过 certbot renew
的方式更新会有问题,报错信息如下:
balabala...
certbot._internal.plugins.disco:Other error:(PluginEntryPoint#manual): An authentication script must be provided with --manual-auth-hook when using the manual plugin non-interactively.
Traceback (most recent call last):File "/usr/lib/python2.7/site-packages/certbot/_internal/plugins/disco.py", line 157, in prepareself._initialized.prepare()File "/usr/lib/python2.7/site-packages/certbot/_internal/plugins/manual.py", line 94, in prepareself.option_name('auth-hook')))
PluginError: An authentication script must be provided with --manual-auth-hook when using the manual plugin non-interactively.
balabala...
PluginSelectionError: 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.',)
此错误大致意思时,如果要更新DNS TXT,由于一开始选择的是 --manual 的方式安装的,那么再次更新需要指定一个 --manual-auth-book参数,此时完整更新命令应该是:
sudo certbot renew \--cert-name your.domain.url.com \--manual \--preferred-challenges dns \--manual-auth-hook /path/to/auth.sh \--manual-cleanup-hook /path/to/clean.sh
关键在于auth.sh
和clean.sh
该如何写。
解决办法
方法一:手动更新
此法思路与安装类似,执行
# 注意替换域名
certbot --manual --preferred-challenges dns -d your.domain.url.com
会输出一个新的 DNS TXT记录,
Please deploy a DNS TXT record under the name
_acme-challenge.your.domain.url with the following value:
08QWAexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxNm4
Before continuing, verify the record is deployed.
Press Enter to Continue
登录云服务器后台的 云解析DNS,进到自己的域名内部,更新 _acme-challenge.your.domain.url 中的TXT配置的记录值即可。
方法二:自动更新
自动更新涉及云服务器配置 SECRET_ID 和 SECRET_KEY ,有一定的信安风险,请慎重选择。
新坑代填。。。。。