申请Let‘s Encrypt证书

 Let's Encrypt官网:https://letsencrypt.org/


Certbot官网:https://certbot.eff.org/

1、域名控制台添加域名,如test.example.com

2、在服务器添加nginx配置,test.example.com.conf文件内容如下

# test.example.com.conf配置

server {
    listen       80;
    server_name  test.example.com;

    location / {
        root   html/example;
        index  index.html index.htm;
    }
}

3、重启nginx

nginx -s reload

4、curl访问

curl test.example.com

5、访问入门指南 - Let's Encrypt - 免费的SSL/TLS证书,我们发现可以使用Certbot工具进行操作

在Certbot页面填写HTTP website的运行环境,如Certbot Instructions | Certbot

根据上面的步骤,依次安装snapdCertbot

# 安装snapd,见https://snapcraft.io/docs/installing-snap-on-centos
yum install snapd
systemctl enable --now snapd.socket
ln -s /var/lib/snapd/snap /snap


# 安装Certbot
snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot

6、申请证书

certbot certonly -a manual -i nginx -d test.example.com


# 1、说明
# 详见:https://eff-certbot.readthedocs.io/en/latest/using.html#nginx
# 
# certonly:只生成证书,后续自行配置
# -a 或 --authenticator:
# -i 或 --installer:
# -d 或 --domains:域名
# --nginx-server-root 可以指定nginx配置文件路径,默认: /etc/nginx 或 /usr/local/etc/nginx
# --webroot-path,简写-w,项目目录


# 2、补充
# 执行上述命令可能需要填写邮箱地址

返回结果

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Requesting a certificate for test.example.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Create a file containing just this data:

zi4-Q2V2Kbr31z1DkmeqlAqFvdaBoKkc0fRI_hMak6A.a8QL3dhhRI6nKqWSrmSGWWYjRocjtI6ew0Xh1rVkRoA

And make it available on your web server at this URL:

http://test.example.com/.well-known/acme-challenge/zi4-Q2V2Kbr31z1DkmeqlAqFvdaBoKkc0fRI_hMak6A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue

根据返回的结果,需要在项目所在的路径创建.well-known/acme-challenge/zi4-Q2V2Kbr31z1DkmeqlAqFvdaBoKkc0fRI_hMak6A这个文件,内容为zi4-Q2V2Kbr31z1DkmeqlAqFvdaBoKkc0fRI_hMak6A.a8QL3dhhRI6nKqWSrmSGWWYjRocjtI6ew0Xh1rVkRoA

# 进入项目目录
cd html/example

# 创建目录、文件
mkdir -p .well-known/acme-challenge
touch .well-known/acme-challenge/zi4-Q2V2Kbr31z1DkmeqlAqFvdaBoKkc0fRI_hMak6A

# zi4-Q2V2Kbr31z1DkmeqlAqFvdaBoKkc0fRI_hMak6A文件内容
# zi4-Q2V2Kbr31z1DkmeqlAqFvdaBoKkc0fRI_hMak6A.a8QL3dhhRI6nKqWSrmSGWWYjRocjtI6ew0Xh1rVkRoA

然后按任意键(Press Enter to Continue)

返回结果

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/test.example.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/test.example.com/privkey.pem
This certificate expires on 2024-03-12.
These files will be updated when the certificate renews.

NEXT STEPS:
- This certificate will not be renewed automatically. Autorenewal of --manual certificates requires the use of an authentication hook script (--manual-auth-hook) but one was not provided. To renew this certificate, repeat this same certbot command before the certificate's expiry date.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

到此,证书申请成功

7、nginx配置ssl证书

# test.example.com.conf配置

server {
    listen       80;
    server_name  test.example.com;

    # 监听443端口
    listen 443 ssl;

    # 配置ssl证书
    # nginx的ssl证书配置参考:https://cloud.tencent.com/document/product/400/35244
    ssl_certificate /etc/letsencrypt/live/test.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/test.example.com/privkey.pem;

    ssl_session_timeout 5m;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;


    location / {
        root   html/example;
        index  index.html index.htm;
    }
}

8、重启nginx

nginx -s reload

9、浏览器访问https://test.example.com,并查看证书信息

10、有效期有限,添加定时任务更新,定时任务执行命令:certbot renew --dry-run

11、申请letsencrypt通配符证书

技术干货 024|如何免费申请通配SSL证书 - 知乎

参考:

Welcome to the Certbot documentation! — Certbot 2.7.0.dev0 documentation

手把手教你搭建基于 Let’s Encrypt 的免费 HTTPS 证书 - 简书

申请 Let'sEncrypt 证书 - 博客园

SSL 证书 Nginx 服务器 SSL 证书安装部署-证书安装-文档中心-腾讯云

技术干货 024|如何免费申请通配SSL证书 - 知乎

  • 8
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
let's encrypt是一个非盈利性质的机构,致力于提供免费的SSL证书服务,以促进整个互联网的安全性。在官网上,他们提供了一键式免费申请SSL证书的脚本,使得用户可以快速而简便地获取自己网站的SSL证书。 这个一键式免费申请SSL证书脚本的使用非常简单。首先,用户需要在自己的网站服务器上安装并配置好Certbot工具。Certbot是一个由let's encrypt官方开发的自动化工具,用于申请和更新SSL证书。 在安装和配置好Certbot之后,用户只需要在命令行中输入一条简单的指令,就可以申请自己网站的SSL证书了。具体指令如下: $ sudo certbot certonly --standalone -d <your_domain> 其中,“<your_domain>”替换为用户自己的域名。这条指令的作用是告诉Certbot以standalone模式运行,并申请一个新的证书,该证书将与用户输入的域名关联。 Certbot会自动与let's encrypt的服务器进行通信,验证用户所拥有的域名和服务器的控制权。一旦验证通过,Certbot就会生成一个有效期为90天的SSL证书,并将其保存在用户指定的位置。 用户可以根据自己的需要选择将证书文件保存到哪个目录,以及将其用于哪个Web服务器(例如Apache或Nginx)。 值得一提的是,这个一键式免费申请SSL证书脚本还支持自动续订证书的功能。Certbot会在证书即将过期之前自动执行更新过程,以确保用户的网站能够持续使用最新的SSL证书。 总之,let's encrypt官网提供的一键式免费申请SSL证书脚本极大地简化了证书申请和管理的过程,让网站拥有更安全可靠的加密通信。用户只需几个简单的步骤,就能轻松获得免费的SSL证书,提升网站的安全性和可信度。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值