前言

随着网站安全需求增加,数字化证书需求越来越多,而对于个人网站而言各个平台的证书价格昂贵,如何获取属于自己的证书呢?学习本文章教你如何免费安装Let’s Encrypt证书(官网:https://letsencrypt.org/)。

什么是Let’s Encrypt

Let’s Encrypt 是一个于 2015 年三季度推出的数字证书认证机构,旨在以自动化流程消除手动创建和安装证书的复杂流程,并推广使万维网服务器的加密连接无所不在,为安全网站提供免费的 SSL/TLS 证书。

老版本问题

certbot-auto不再支持所有的操作系统!根据作者的说法,certbot团队认为维护certbot-auto在几乎所有流行的UNIX系统以及各种环境上的正常运行是一项繁重的工作,加之certbot-auto是基于python 2编写的,而python 2即将寿终正寝,将certbot-auto迁移至python 3需要大量工作,这非常困难,因此团队决定放弃certbot-auto的维护。

安装

1.将EPEL添加到CentOS 7

yum install epel-release

2.安装snapd

yum install snapd

3.安装后,需要启用用于管理主快照通信套接字

systemctl enable --now snapd.socket

4.建立软链接

ln -s /var/lib/snapd/snap /snap

5.更新snap

snap install core

snap refresh core

6.使用snap命令安装certbot

snap install --classic certbot

7.建立软链接

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

8.生成证书(手动安装插件)

certbot certonly --email 邮箱 -d *.网站.com --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory

9.配置域名解析值TXT

10.找到证书路径

/etc/letsencrypt/live/xxx/xxx.pem

11.查看证书有效期

openssl x509 -noout -dates -in /etc/letsencrypt/live/xxx.com/cert.pem

12.找到nginx根目录添加证书支持

./configure --prefix=/usr/local/nginx --with-http_ssl_module

make

cp obj/nginx /usr/nginx/sbin

13.配置证书

vim /usr/nginx/conf/nginx.conf
listen 443 ssl;

ssl_certificate "/etc/letsencrypt/live/xxxxx.com/cert.pem";

ssl_certificate_key "/etc/letsencrypt/live/xxxxx.com/privkey.pem";

server_tokens off; ssl_protocols TLSv1.2; server_name www.xxxxx.com;

14.重新加载nginx

sh nginx -s reload

15.添加定时任务给证书续期

crontab -e
0 0 1 1,15 * certbot renew && sh /usr/nginx/sbin/nginx -s reload

16.至此证书安装成功并完成了自动续签

原文地址https://www.saintnong.com/info?id=1672440631083065346

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐