阿水的世界。

2021年6月

06月 25

更新Let's Encrypt SSL证书(通过DNS方式验证)

刚刚,网站的Let's Encrypt SSL到期了,需要更新一下证书,但是不想通过80端口自动更新,想使用DNS验证的方式手动更新,
现在服务器已经安装过certbot,使用这个命令certbot-auto --manual --preferred-challenges dns certonly更新证书。
如果遇到这个错误:

Upgrading certbot-auto X.XX to X.XX.X...

Couldn't download https://raw.githubusercontent.com/certbot/certbot/v0.XX.0/letsencrypt-auto-source/letsencrypt-auto. <urlopen error [Errno 110] Connection timed out>

原因是:certbot-auto将始终尝试从最新版本中获取自身的最新版本。

解决方案:在命令后加 --no-self-upgrade 即可。即:

certbot-auto --manual --preferred-challenges dns certonly --no-self-upgrade

运行后,根据提示输入单个或多个域名,多个域名中间用英文逗号隔开,再次显示:

Please deploy a DNS TXT record under the name
_acme-challenge.XXXX.com with the following value:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Before continuing, verify the record is deployed.

这时需要更新域名的_acme-challenge解析值,解析完成后,使用nslookup命令可以查到相应的解析后,再点继续。
具体查询命令如下:

$ nslookup
> set type=txt
> _acme-challenge.XXXX.com
Server:    223.5.5.5
Address:    223.5.5.5#53

Non-authoritative answer:
_acme-challenge.XXXX.com    text = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

certbot提示证书更新成功后,重启网站服务即可。
lnmp重启nginx命令:sudo lnmp nginx restart

至此,SSL更新完成。