Let's Encrypt 是一家免费、开放、自动化的证书颁发机构 (CA)。记录一下使用Let's Encrypt的过程。
Let's Encrypt ACME 地址如下:
https://acme-v02.api.letsencrypt.org/directory
使用的是certbot ACME客户端
可以参考官网的安装
https://certbot.eff.org/instructions?ws=nginx&os=pip
系统是Centos使用yum安装py3 和 lib
sudo yum install python3 augeas-libs
如果以前有 certbot-auto或者任何Certbot OS 包,需要提前删除
yum remove certbot
设置Python环境
sudo python3 -m venv /opt/certbot/
sudo /opt/certbot/bin/pip install --upgrade pip
安装certbot
sudo /opt/certbot/bin/pip install certbot
准备certbot命令
sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot
选择你如何运行certbot
我这里使用的命令是
安装模式 certonly
指定统配域名 -d *.zhuiyv.me
手动 --manual
使用dns验证你的服务器 --preferred-challenges dns
服务地址是上面的ACME 地址 --server https://acme-v02.api.letsencrypt.org/directory
certbot certonly -d *.zhuiyv.me--manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory
命令执行后会需要输入邮箱用来做一些提醒
输入邮箱后会要你同意 Let's Encrypt 协议要求
问你是否分享你的邮箱
以及确认绑定IP
如果提醒
The only valid version for X509Req is 0.
说明没有ssl生成工具
可以使用
/opt/certbot/bin/pip install pyOpenSSL==23.1.1
安装pyOpenSSL
确认后需要先去做域名解析,先不要动终端

根据给出的提示去域名管理做一条TXT的域名解析,解析值为提示给的内容
配置完域名解析后,可以使用
https://toolbox.googleapps.com/apps/dig/#TXT/_acme-challenge.zhuiyv.me
验证域名是否生效,生效之后再在控制台点确认下一步
生成成功后会显示对应的文件地址

添加配置到nginx配置
ssl_certificate /etc/letsencrypt/live/xxxxxx/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/xxxxxx/privkey.pem;

nginx -t
nginx -s reload
// 编辑定时任务
crontab -e
定时renew /usr/local/nginx/sbin/nginx 替换为该使用的nginx路径
0 */12 * * * certbot renew --quiet --renew-hook "/usr/local/nginx/sbin/nginx -s reload"
有待观察定时任务是否正常
删除 取消 我还没用过
certbot revoke --cert-path /etc/letsencrypt/live/you.cn/cert.pem
certbot delete --cert-name you.cn