前言
项目要求需要快速发布上线,快速生成证书。
Let’s Encrypt 是一个免费 SSL 证书发行项目,自动化发行证书,证书有 90 天的有效期。
安装过程
pip uninstall requestspip uninstall urllib3yum remove python-urllib3yum remove python-requestsyum install python2-certbot-nginxyum install python-urllib3yum install python-requestsyum install certbotyum install certbot-nginx#第一次使用certbotcertbot certonly#输入邮箱XXX@XX.com#是否接受信息Yes|No#输入解析到本机的域名并生成证书XXXX.XXX.com
其他影响
#需要在python3安装前先装好certbot否则影响python3使用,或者说 python3 影响yum(ansible中的yum)
#修改#!/usr/bin/python >> #!/usr/bin/python2
- /usr/bin/yum
- /usr/bin/pip
- /usr/libexec/urlgrabber-ext-down
#默认是/etc/nginx/nginx.conf
certbot certonly --nginx-server-root=/data/nginx/conf --nginx
自动续期
。于是有了另外一个项目可以自动安装,自动续期。
解决方案
#手动测试,查看证书过期时间
certbot renew
#忽略证书过期时间,直接重置证书时间
certbot renew --force-renewal
#定时任务
crontab -e
#编辑文件
0 0 1 * * /usr/bin/certbot renew --force-renewal
定时每天检查,如果要过期则自动延期。
