介绍
威盒官网全站升级HTTPS,原来使用的七牛云,免费流量不支持HTTPS,因此更换成腾讯云。证书使用Let’s Encrypt的泛域名证书。问题是证书每三个月需要更换一次,腾讯云提供的相应的API。
腾讯云社区找到有人写好了脚本,是python2的,改成了python3,而且使用acme.sh也有一些细微的变化,稍微修改了一下。(HTTPS 证书配置一劳永逸)
使用
首先需要申请腾讯云 Token 在这里不做介绍。
安装acme.sh
1
| curl https://get.acme.sh | sh
|
acme.sh支持DNS验证的方式申请证书,只需要添加一个域名DNS解析商的Token,一切全自动。
我们使用的是DNSPOD的DNS服务,acme.sh支持DNSPOD的API。
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 32 33 34 35
| export DP_Id="1234" export DP_Key="sADDsdasdgdsf" cron脚本 #!/bin/bash #************************************************* # Description : CRON # Version : 1.0 # Author : XABCLOUD.COM #************************************************* #-----------------VAR----------------------------- HOME=/home/klzy BIN=$HOME/qcloud CA=$HOME/.acme.sh/vlabpro.com #-----------------FUN----------------------------- ACME(){ for domain in vlabpro.com do cd $HOME/.acme.sh/;./acme.sh --issue --dns dns_dp -d $domain -d *.$domain --force done } UP_SSL(){ key=$(cat $CA/vlabpro.com.key|base64) pem=$(cat $CA/fullchain.cer|base64) for domain in store.vlabpro.com do python $BIN/qcloud-cdn.py SetHttpsInfo --host $domain --privateKey "$key" --cert "$pem" --httpsType "1" done #find $CA -type f ! -name "*.pem" -a ! -name "*.key" -delete } main(){ ACME UP_SSL } #-----------------PROG---------------------------- main
|
python程序
qcloud-cdn.py