摘要:
Let's Encrypt作为一个公共且免费SSL,目前Let's Encrypt免费SSL证书默认是90天有效期,但是我们也可以到期自动续约。
参考搬砖内容:
GitHub - acmesh-official/acme.sh: A pure Unix shell script implementing ACME client protocolA pure Unix shell script implementing ACME client protocol - GitHub - acmesh-official/acme.sh: A pure Unix shell script implementing ACME client protocolhttps://github.com/acmesh-official/acme.sh
注意事项:
1/申请证书的服务器需要能访问到海外网络,国内服务器经常不行。
2/安装Let's Encrypt部署之前需要服务器支持PYTHON2.7以及GIT环境,要不无法部署。(我使用系统:CentOS7.9)
3/Let's Encrypt默认是90天免费,需要手工或者自动续期才可以继续使用。
下载Let's Encrypt部署包。
curl https://get.acme.sh | sh -s email=my@example.com
[root@HK_zwf ~]# curl https://get.acme.sh | sh -s email=company@zhongwf.cn
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 937 0 937 0 0 310 0 --:--:-- 0:00:03 --:--:-- 310
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 205k 100 205k 0 0 99k 0 0:00:02 0:00:02 --:--:-- 99k
[2022年 02月 10日 星期四 16:44:27 CST] Installing from online archive.
[2022年 02月 10日 星期四 16:44:27 CST] Downloading https://github.com/acmesh-official/acme.sh/archive/master.tar.gz
[2022年 02月 10日 星期四 16:44:29 CST] Extracting master.tar.gz
[2022年 02月 10日 星期四 16:44:32 CST] It is recommended to install socat first.
[2022年 02月 10日 星期四 16:44:32 CST] We use socat for standalone server if you use standalone mode.
[2022年 02月 10日 星期四 16:44:32 CST] If you don't use standalone mode, just ignore this warning.
[2022年 02月 10日 星期四 16:44:32 CST] Installing to /root/.acme.sh
[2022年 02月 10日 星期四 16:44:32 CST] Installed to /root/.acme.sh/acme.sh
[2022年 02月 10日 星期四 16:44:33 CST] Installing alias to '/root/.bashrc'
[2022年 02月 10日 星期四 16:44:33 CST] OK, Close and reopen your terminal to start using acme.sh
[2022年 02月 10日 星期四 16:44:33 CST] Installing alias to '/root/.cshrc'
[2022年 02月 10日 星期四 16:44:33 CST] Installing alias to '/root/.tcshrc'
[2022年 02月 10日 星期四 16:44:33 CST] Installing cron job
no crontab for root
no crontab for root
[2022年 02月 10日 星期四 16:44:34 CST] Good, bash is found, so change the shebang to use bash as preferred.
[2022年 02月 10日 星期四 16:44:37 CST] OK
[2022年 02月 10日 星期四 16:44:37 CST] Install success!
路径:cd /root/.acme.sh/
[root@HK_zwf ~]# cd /root/.acme.sh/
[root@HK_zwf .acme.sh]# ll
总用量 236
-rw-r--r--. 1 root root 186 2月 21 16:54 account.conf
-rwxr-xr-x. 1 root root 210285 2月 21 16:54 acme.sh
-rw-r--r--. 1 root root 78 2月 21 16:54 acme.sh.csh
-rw-r--r--. 1 root root 78 2月 21 16:54 acme.sh.env
drwxr-xr-x. 2 root root 4096 2月 21 16:54 deploy
drwxr-xr-x. 2 root root 4096 2月 21 16:54 dnsapi
drwxr-xr-x. 2 root root 4096 2月 21 16:54 notify
修改配置:vim acme.sh 我的域名在阿里云,其他域名也一样的。
阿里云的https://ram.console.aliyun.com/manage/ak AccessKey 在第四行加入就好了。
[root@HK_zwf .acme.sh]# vim acme.sh
1 #!/usr/bin/bash
2
3 VER=3.0.2
4
5 export Ali_Key="LTAI5t5zXXXXXXXXXXXvS3gvG" 阿里云的AccessKey
6 export Ali_Secret="xvfNj70XXXXXXXXXXXINz4"
7
8 PROJECT_NAME="acme.sh"
三/生成证书
sh acme.sh --issue --dns dns_ali -d zhongwf.cn -d *.zhongwf.cn (修改自己的域名)
[root@HK_zwf .acme.sh]# sh acme.sh --issue --dns dns_ali -d zhongwf.cn -d *.zhongwf.cn
[2022年 02月 10日 星期四 16:48:23 CST] Using CA: https://acme.zerossl.com/v2/DV90
[2022年 02月 10日 星期四 16:48:25 CST] Create account key ok.
[2022年 02月 10日 星期四 16:48:25 CST] No EAB credentials found for ZeroSSL, let's get one
[2022年 02月 10日 星期四 16:48:26 CST] Registering account: https://acme.zerossl.com/v2/DV90
[2022年 02月 10日 星期四 16:48:31 CST] Registered
.........................
-----END CERTIFICATE-----
[2022年 02月 10日 星期四 16:50:14 CST] Your cert is in: /root/.acme.sh/zhongwf.cn/zhongwf.cn.cer
[2022年 02月 10日 星期四 16:50:14 CST] Your cert key is in: /root/.acme.sh/zhongwf.cn/zhongwf.cn.key
[2022年 02月 10日 星期四 16:50:14 CST] The intermediate CA cert is in: /root/.acme.sh/zhongwf.cn/ca.cer
[2022年 02月 10日 星期四 16:50:14 CST] And the full chain certs is there: /root/.acme.sh/zhongwf.cn/fullchain.cer
三/查看证书
[root@HK_zwf .acme.sh]# ll
总用量 236
-rw-r--r-- 1 root root 349 2月 10 16:50 account.conf
-rwxr-xr-x 1 root root 210379 2月 10 16:47 acme.sh
-rw-r--r-- 1 root root 78 2月 10 16:44 acme.sh.csh
-rw-r--r-- 1 root root 78 2月 10 16:44 acme.sh.env
drwxr-xr-x 3 root root 30 2月 10 16:48 ca
drwxr-xr-x 2 root root 4096 2月 10 16:44 deploy
drwxr-xr-x 2 root root 4096 2月 10 16:44 dnsapi
drwxr-xr-x 2 root root 152 2月 10 16:50 zhongwf.cn
-rw-r--r-- 1 root root 383 2月 10 16:50 http.header
drwxr-xr-x 2 root root 313 2月 10 16:44 notify