赞
踩
最近https到期了,想着手动更新一下https证书,结果发现证书现在的有效期只有90天,于是想找到一个自动更新证书的工具,发现了acme.sh,但是网上的文章质量参差不齐,可能需要多篇文章结合来操作,一步步试错。我这里结合了腾讯云的相关文档和一些其他的博文,保证一次性操作成功。
git clone https://gitee.com/neilpang/acme.sh.git
注意换成自己的邮箱号
./acme.sh --install -m xxxx@163.com
acme.sh --upgrade --auto-upgrade
因为ZeroSSL可以支持泛域名,所以这里我就选择了ZeroSSL。
acme.sh --set-default-ca --server zerossl
acme.sh --register-account -m acurd_com@163.com --server zerossl
SecretId
AKIDHVYSCnFXEkKrCMLBxxxx
SecretKey
Ef8SZTFrQvTwEPRGulxxxxx
export Tencent_SecretId="xxxxx"
export Tencent_SecretKey="xxxxx"
其中*.acurd.com
是泛域名,acurd.com
是根域名,
acme.sh --dns dns_tencent --issue -d *.acurd.com -d acurd.com
命令执行完毕,证书即颁发下来了
创建目录用来存储ssl
mkdir -p /home/ssl/acurd.com
acme.sh --installcert -d *.acurd.com \
--key-file /home/ssl/acurd.com/*.acurd.com.key \
--fullchain-file /home/ssl/acurd.com/fullchain.cer \
--reloadcmd "service nginx reload"
ls /home/ssl/acurd.com
[root@iZ2zeguqeswvn0s3zfrlyfZ acme.sh]# ls /home/ssl/acurd.com/
*.acurd.com.key fullchain.cer
# 请替换为证书实际路径
ssl_certificate /home/ssl/acurd.com/fullchain.cer;
ssl_certificate_key /home/ssl/acurd.com/*.acurd.com.key;
acme.sh --installcert -d acurd.com \
--key-file /home/ssl/root/acurd.com.key \
--fullchain-file /home/ssl/root/fullchain.cer \
--reloadcmd "service nginx reload"
现在我们已经配置好了https,那么怎么实现自动续期呢,基于crontab我们就可以实现了,我们先写一个脚本refresh_https.sh
[root@iZ2zeguqeswvn0s3zfrlyfZ /]# vi /usr/local/acme.sh/refresh_https.sh #!/bin/bash # 切换到 acme.sh 目录 cd /usr/local/acme.sh ./acme.sh --dns dns_tencent --issue -d *.acurd.com -d acurd.com # 执行 acme.sh 命令获取证书 ./acme.sh --installcert -d *.acurd.com \ --key-file /home/ssl/acurd.com/*.acurd.com.key \ --fullchain-file /home/ssl/acurd.com/fullchain.cer \ --reloadcmd "service nginx reload" # 退出脚本 exit 0
0 0 1 2,4,6,8,10,12 * /usr/local/acme.sh/refresh_https.sh
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。