啊。啊。啊。https免费证书又到期了怎么办。。。。

这两天在“互联网大厂”批量申请的免费证书又到期了,每次都要重新批量申请->上传->导入配置,已经忘记这是第几次了,身心疲惫。。。。

有没有一个一劳永逸的办法呢?

Let's Encrypt!!!

Let's Encrypt 是一个公共且免费SSL的项目,是由Mozilla、Cisco、Akamai、IdenTrust、EFF等组织人员发起,其因“让所有人都能容易、自动、免费的获得TLS证书”的理念被逐渐被广大用户传播和使用。

因其“容易”的特点,我们不需要太多设置就可以直接上手使用(一切的繁琐配置都是耍流氓!)

certbot是EFF基金会推荐使用的一款Let's Encrypt客户端,certbot提供从证书获-证书安装-web服务器的一条龙服务

安装certbot:

debian/ubuntu:

1、apt安装:

& sudo apt install certbot

如果使用apache,安装如下certbot插件
& sudo apt install python3-certbot-apache

如果使用nginx安装如下certbot插件
& sudo apt install python3-certbot-nginx

2、推荐snap安装(适合所有支持snap商店的linux系统):

更新snap:

sudo snap install core; sudo snap refresh core

安装:

sudo snap install certbot --classic
创建软链:
sudo ln -s /snap/bin/certbot /usr/bin/certbot

3、生成nginx证书:

运行此命令以获取证书并让 Certbot 自动编辑 nginx 配置以提供服务,只需一步即可打开 HTTPS 访问。

sudo certbot --nginx

生成Apache证书:

sudo certbot --apache

如果运行正常的话,会提示输入邮箱

邮箱输入后会列出服务器上配置的域名

按编号依次输入,或者留空选择全部

4、如果只想获取证书并手动配置:

sudo certbot certonly --nginx

5、指定web路径和域名:

sudo certbot certonly --webroot -w <你的web根目录> -d <你的域名>

生成的证书会被放到/etc/letsencrypt/live/<你的域名>

使用该方法,你必须确保这个域名属于你,并且你的域名在当前服务器中的80或者443端口可访问性。

否则,你会看到如下错误:

& sudo certbot certonly --webroot -w /var/www/html/test -d www.csdn.net


Challenge failed for domain www.csdn.net
IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: www.csdn.net
   Type:   unauthorized
   Detail: Invalid response from
   https://www.csdn.net/.well-known/acme-challenge/c5SqFfbQkFCxaF-NKA3jMSlYiXZat0oeTaCvD8PoOGU
   [39.106.226.142]: 404

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A/AAAA record(s) for that domain
   contain(s) the right IP address.
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.

6、关于自动续订:

Certbot 软件包带有一个 cron 作业或 systemd 计时器,可在证书到期之前自动更新您的证书。除非您更改配置,否则您无需再次运行 Certbot。您可以通过运行以下命令来测试证书的自动续订:

sudo certbot renew --dry-run

7、更新 certbot 的命令安装在以下位置之一:

  • /etc/crontab/
  • /etc/cron.*/*
  • systemctl list-timers

最后,通过https://yourwebsite.com/访问,开始你的骚操作吧

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值