免费TLS--Let's Encrypt 使用说明

  • Let's Encrypt:这是一个由非营利性组织互联网安全研究小组(ISRG)提供的免费、自动化和开放的证书颁发机构。它为众多网站提供 TLS 证书,其免费证书的签发/续签可以通过脚本自动化完成。Let's Encrypt 免费证书的有效期通常为90天。官方网站为:https://letsencrypt.org/zh-cn/

根据官网https://letsencrypt.org/zh-cn/getting-started/的说明,申请免费的TLS需要三个条件
1.你有一个域名并且已经绑定了你的云主机ip
2.你有云主机的ssh登录权限
3.你的ssh账户有sudo权限

如果上面的需求你都满足了,那么就可以按照流程申请免费的TLS了
流程是 下载安装snapd-->用snapd下载安装certbot-->利用certbot申请TLS证书并自动续约

下载安装snapd,官网 https://snapcraft.io/docs/installing-snapd

#安装snapd
sudo yum install snapd
#Once installed, the systemd unit that manages the main snap communication socket needs to be enabled
sudo systemctl enable --now snapd.socket
#enable classic snap support
sudo ln -s /var/lib/snapd/snap /snap
#这里需要重启一下才能保证后续的正常下载
sudo systemctl restart snapd.service

用snapd下载安装certbot,并申请证书

#安装certbot
sudo snap install --classic certbot
#添加软连接
sudo ln -s /snap/bin/certbot /usr/bin/certbot
#运行此命令以获取证书,并让 Certbot 自动编辑您的 nginx 配置以提供它,只需一步即可打开 HTTPS 访问
sudo certbot --nginx
#如果您感觉更保守,并希望手动更改 nginx 配置,请运行此命令
sudo certbot certonly --nginx
#系统上的 Certbot 软件包附带一个 cron 作业或 systemd 计时器,它将在证书过期之前自动续订证书。除非您更改配置,否则您无需再次运行 Certbot。
#您可以通过运行以下命令来测试证书的自动续订
sudo certbot renew --dry-run

我使用的是sudo certbot certonly --nginx,所以我运行后会得到以下提示

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/yourwebsite.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/yourwebsite.com/privkey.pem
This certificate expires on 2023-12-26.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

现在可以配置你的nginx后开始使用https了。
这里只展示了nginx的使用样例,如果要用其他方式配置TLS可以去certbot官网查看对应的使用方法。



posted on   zhangzongshan  阅读(230)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示