侧边栏壁纸
  • 累计撰写 176 篇文章
  • 累计创建 87 个标签
  • 累计收到 1 条评论

目 录CONTENT

文章目录

certbot自动申请和续期https证书

Z先森
2024-05-23 / 0 评论 / 0 点赞 / 40 阅读 / 0 字 / 正在检测是否收录...

现在免费证书时间越来越短,自动申请和续期已经提上议程了,记录一下操作方法。

一、安装certbot

yum install certbot

二、证书生成

通过网站目录自动建文件的校验方式只能通过-d参数手动配置多个域名,如果需要通配符域名,则需要通过API对接DNS解析商来自动加解析

certbot certonly --webroot -w 「站点目录」 -d maxbon.cn -d www.maxbon.cn

三、nginx修改路径

ssl_certificate /etc/letsencrypt/live/maxbon.cn/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/maxbon.cn/privkey.pem;

四、任务计划设置自动更新(每月1日)

certbot会自动检测证书是否过期,没过期不会更新(貌似是到期前1个月内就可以更新了)

00 00 01 * * certbot renew && nginx -s reload

补充一个泛域名的

git clone https://gitee.com/neilpang/acme.sh.git
cd acme.sh
./acme.sh --issue --dns -d maxbon.cn -d *.maxbon.cn --yes-I-know-dns-manual-mode-enough-go-ahead-please --register-account -m admin@maxbon.cn

账号注册后,再执行

./acme.sh --issue --dns -d maxbon.cn -d *.maxbon.cn --yes-I-know-dns-manual-mode-enough-go-ahead-please

会提示添加TXT解析到DNS,按提示操作即可,添加完之后,再次执行:

./acme.sh --issue --dns -d maxbon.cn -d *.maxbon.cn --yes-I-know-dns-manual-mode-enough-go-ahead-please --renew

大概1分钟左右,就完事了

0

评论区