一、Certbot 简介

是Let's Encrypt官方推荐的获取证书的客户端,可以帮我们获取免费的Let's Encrypt 证书。Certbot 是支持所有 Unix 内核的操作系统的。

sudo yum install snapd               #安装 snapd
sudo snap install --classic certbot  #使用snapd安装 Certbot
sudo ln -s /var/lib/snapd/snap /snap #创建软链接保证命令

二、申请证书

执行证书生成命令,去云服务商后台增加一条dns,并将certbot生成的参数填写到dns配置的相关位置

certbot certonly -d *.lius.fun --manual --preferred-challenges dns
  • certonly 表示安装模式,Certbot 有安装模式和验证模式两种类型的插件
  • -d 为那些主机申请证书,如果是通配符,输入 *.example.com
  • --manual 表示手动安装插件,Certbot 有很多插件,不同的插件都可以申请证书,用户可以根据需要自行选择
  • --preferred-challenges dns 使用 DNS 方式校验域名所有权

[button color="light" icon="" url="https://letsencrypt.org/docs/challenge-types/#http-01-challenge" type=""]其他挑战方式[/button]

三、自动申请

Let’s Encrypt 证书将在 90 天后到期。我们建议您自动更新证书。此处,我们将一个 cron 作业添加到现有 crontab 文件中,以执行这一操作。

  1. 打开 crontab 文件
$ crontab -e
  1. 添加certbot命令,并设置为每天运行。在本例中,我们每天中午运行该命令。该命令检查服务器上的证书是否会在未来 30 天内到期,如果是,则更新证书
0 12 * * * /usr/bin/certbot renew --quiet

[scode type="share"]-quiet指令告知certbot不要生成输出[/scode]

四、手动申请

手动申请需要进行DNS挑战,请注意开启
cd /etc/letsencrypt/renewal
cat lius.fun.conf
certbot certonly --email gua3j7@126.com -d *.lius.fun --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory

标签: none

添加新评论