使用certbot命令和定时任务(crontab)自动更新 let’s encrypt证书

栏目: 服务器 · 发布时间: 7年前

内容简介:let’s encrypt提供免费的

let’s encrypt提供免费的 https 证书,使用非常方便。可以在线自动更新,目前一个证书的有效期只有90天,所以90天内,至少要更新一次证书。所以可以通过定时任务 crontablet’s encrypt 提供的证书管理工 certbot ,可以实现对证书的自动管理,可以对证书进行管理(增加,删除)等操作。

使用crontab 对证书进行自动管理

crontab -e 增加两条定时任务

# 每月的 1,7,21,28号, 4点30 更新证书
30 4 1,7,21,28 * * /usr/bin/certbot-2 renew
# 每月的 1,7,21,28号, 5点30 重新启动nginx 服务器
30 5 1,7,21,28 * * /usr/sbin/nginx -t && killall  nginx  && /usr/sbin/nginx

查看当前的证书信息

certbot certificates 查看当前的所有的证书信息

certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
  Certificate Name: liuhaolin.com
    Domains: liuhaolin.com www.liuhaolin.com
    Expiry Date: 2019-04-03 23:25:43+00:00 (VALID: 89 days)
    Certificate Path: /etc/letsencrypt/live/liuhaolin.com/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/liuhaolin.com/privkey.pem

默认的情况,证书到期前30天,执行 certbot renew 证书才会更新,每个证书有个配置文件。默认在文件夹 /etc/letsencrypt/renewal 下,有每个证书的信息。

cat /etc/letsencrypt/renewal/www.liuhaolin.com.conf

使用certbot命令和定时任务(crontab)自动更新 let’s encrypt证书

可以看到第一行的 renew_before_expiry = 30 days 意思是,距离证书到期时间为30天以内的时候,执行更新证书的命令 certbot-2 renew 才会更新证书。


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Hacking

Hacking

Jon Erickson / No Starch Press / 2008-2-4 / USD 49.95

While other books merely show how to run existing exploits, Hacking: The Art of Exploitation broke ground as the first book to explain how hacking and software exploits work and how readers could deve......一起来看看 《Hacking》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具