官方推荐使用snap安装
Unless you have very specific requirements, we kindly suggest that you use the installation instructions for your system found at https://certbot.eff.org/instructions.

image.png

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# 查看系统版本
cat /etc/centos-release

# 安装snapd
yum install snapd

# 安装后,需要启用管理snap通信套接字的systemd unit
systemctl enable --now snapd.socket

# 为了启用classic snap的支持,需要创建如下软连接
ln -s /var/lib/snapd/snap /snap

# 重启后
snap install core
snap refresh core

# 安装certbot
snap install --classic certbot

ln -s /snap/bin/certbot /usr/bin/certbot

# 验证方式
# https://letsencrypt.org/zh-cn/docs/challenge-types/
# 建议使用dns txt记录验证
# https://eff-certbot.readthedocs.io/en/stable/using.html#manual

certbot --manual certonly --preferred-challenges=dns

# 根据certbot提示,会让输入用户名与邮箱
# 然后输入需要解析的域名,certbot就会输出一个txt内容
# 此时需要把这个内容放到指定的txt解析域名下(一般是_acme-challenge)
# 查看txt域名解析,解析值对上certbot输出的内容后,再下一步
dig TXT <yourdomain.com>

# 查看证书
certbot certificates


# 常规续订
certbot renew

# 删除证书
certbot delete --cert-name <example.com>
# or to choose from a list:
certbot delete

额外续订操作

使用 --manual 创建的证书不支持自动续订,除非通过 --manual-auth-hook 与身份验证挂钩脚本结合使用以自动设置所需的 HTTP 和/或 TXT 质询。
image.png

详细文档
强行使用cerbot renew 会报错
image.png

由于是通过外部信息进行验证,所以需要添加验证身份的脚本验证成功后才能续订
Renewal with the manual plugin

1
2
# 
certbot certonly --manual --manual-auth-hook /path/to/http/authenticator.sh --manual-cleanup-hook /path/to/http/cleanup.sh -d secure.example.com

具体例子可以看官网
Pre and Post Validation Hooks

本质上这种方法相当于把手动续订自动化了,通过API创建DNS Record,后续使用certbot renew 就会去执行这个脚本,然后更新(类似于续订)
如果域名注册网站没有提供操作DNS Record的API那么也是不行的。