Let's Encrypt SSL证书通过DNS TXT记录交互模式手动续期

三个月时间到了,证书需要续期,在网上找了好久都是通过脚本自动执行的方式进行续期的,在这里都不适用,通过参考各种资料和摸索,找到以下方法供参考:

sudo certbot certonly --renew-by-default -d YOURDOMAIN --manual --preferred-challenges dns

certonly 只申请证书
--renew-by-default 通过默认配置更新证书
-d YOURDOMAIN 需要更新证书的域名
--manual 交互方式执行
--preferred-challenges dns 通过DNS TXT记录的方式进行认证

执行以上命令后返回如下结果:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Renewing an existing certificate
Performing the following challenges:
dns-01 challenge for YOURDOMAIN

-------------------------------------------------------------------------------
NOTE: The IP of this machine will be publicly logged as having requested this
certificate. If you're running certbot in manual mode on a machine that is not
your server, please ensure you're okay with that.

Are you OK with your IP being logged?
-------------------------------------------------------------------------------
(Y)es/(N)o:

输入 Y后返回:

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

Fhx3AXM****************e4TchYU

Once this is deployed,
-------------------------------------------------------------------------------
Press Enter to Continue

此时登录域名管理后台,添加_acme-challenge.YOURDOMAIN域名的TXT记录,值为Fhx3AXM****************e4TchYU,保存后输入以下命令进行确认已经正常解析:
dig -t txt _acme-challenge.YOURDOMAIN
如果返回结果中有上面填写的值说明已经添加并解析成功,此时返回证书更新界面按回车继续.正常情况下会返回如下结果.

Waiting for verification...
Cleaning up challenges
Generating key (2048 bits): /etc/letsencrypt/keys/0001_key-certbot.pem
Creating CSR: /etc/letsencrypt/csr/0001_csr-certbot.pem

THE END