首页 > 其他分享 >Letsencrypt

Letsencrypt

时间:2023-02-18 20:46:53浏览次数:35  
标签:证书 -- sudo nginx Letsencrypt com certbot

一、环境

1. CentOS 7.9 2009

2. Cerbot 2.3.0

3. 简介

为了在网站上启用 HTTPS,需要从证书颁发机构(CA)获取证书。 Let’s Encrypt 正是其中一家证书颁发机构。

要从Let’s Encrypt获取网站域名的证书,必须证明你对域名的实际控制权。这一过程通常由 Web 主机上运行的ACME协议客户端完成。

4. 准备

我们以example.com为例,假设它的IP地址为10.8.9.1。

(1) 首先在域名平台配置example.com的域名解析:

@        IN A 10.8.9.1
www   IN A 10.8.9.1
mail    IN A 10.8.9.1

@ IN MX 10 mail.example.com.

(2) 验证配置(Windows CMD)

nslookup -qt=A example.com
nslookup -qt=A www.example.com
nslookup -qt=A mail.example.com

nslookup -qt=MX example.com

二、Cerbot

Cerbot是一个ACME 客户端,它可以在不下线服务器的前提下自动执行证书颁发和安装。对于不需要自动配置的用户,Certbot还提供专家模式。

1. 安装

(1) 更新snap

sudo snap install core
sudo snap refresh core

参考:snap的安装

(2)  注意

如果你是使用yum安装的cerbot,那么你需要先卸载掉它:

sudo yum remove certbot

(3) 安装cerbot

sudo snap install --classic certbot

(4) 创建软链接

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

2. 生成证书

(1) 获取证书并更新Nginx的配置文件

sudo certbot --nginx

(2) 仅仅生成证书

sudo certbot certonly --nginx

3. 定时更新证书

Letsencrypt证书的有效期是90天,官方建议每隔60天自动更新一下证书以避免证书过期。

(1) 可以定时运行以下命令以便自动更新证书:

sudo certbot renew --dry-run

(2) Crontab

a. 编辑Crontab

sudo crontab -e

b. 添加证书更新条目:

* * *  1  * certbot certonly --nginx
* * *  3  * certbot certonly --nginx
* * *  5  * certbot certonly --nginx
* * *  7  * certbot certonly --nginx
* * *  9  * certbot certonly --nginx
* * *  11  * certbot certonly --nginx

三、参考

1. 官方

https://letsencrypt.org/

https://certbot.eff.org/

标签:证书,--,sudo,nginx,Letsencrypt,com,certbot
From: https://www.cnblogs.com/eagle6688/p/17110578.html

相关文章