ssl证书生成
域名证书类型分 DV(域名型)/ OV(企业型)/ EV(企业加强型)等(具体区别参考:https://www.myssl.cn/home/article-61.html),安全等级(从小到大):DV > OV > EV
域名证书提供商有很多,Let’s Encrypt 则是 DV 证书的免费提供商,Let’s Encrypt 证书有效期只有 3 个月,所以需要 3 到期前重新生成。
acme.sh
是生成 Let’s Encrypt 证书的工具。
acme.sh
安装 # 安装程序
curl https://get.acme.sh | sh
# 刷新
source ~/.bashrc
生成证书
自动生成
1. 登录云服务器控制台,找到【Access Key 管理】并生成 Key 和 Secret
2. 查看对应的 dns 脚本找到对应的变量名
在下方网站中搜索自己服务器提供商的脚本,比如
dns_jd.sh
,打开找到 Key 和 Secret 的变量名,比如JD_ACCESS_KEY_ID
JD_ACCESS_KEY_SECRET
https://github.com/acmesh-official/acme.sh/tree/master/dnsapi
3. 执行命令添加全局配置项
export JD_ACCESS_KEY_ID="5B9584FDF4B95"
export JD_ACCESS_KEY_SECRET="5B9584FDF4B95"
4. 申请证书
acme.sh --issue --dns dns_jd -d test.com -d *.test.com
5. 生成证书
acme.sh --installcert -d newyetai.com -d *.newyetai.com --keypath /etc/ssl/newyetai.com/newyetai.com.key --fullchainpath /etc/ssl/newyetai.com/newyetai.com.key.pem --reloadcmd "service nginx force-reload"
参考资料
操作示例:
配置
export Ali_Key="5B9584FDF4B95"
export Ali_Secret="5B9584FDF4B95"
申请证书
acme.sh --issue --dns dns_ali \
-d newyetai.com -d *.newyetai.com \
-d newyetai.cn -d *.newyetai.cn \
-d nuyatax.com -d *.nuyatax.com \
-d nuyatax.cn -d *.nuyatax.cn \
-d niuyetai.com -d *.niuyetai.com \
-d niuyetai.cn -d *.niuyetai.cn \
-d alitatest.cn -d *.alitatest.cn
生成证书
acme.sh --installcert \
-d newyetai.com -d *.newyetai.com \
-d newyetai.cn -d *.newyetai.cn \
-d nuyatax.com -d *.nuyatax.com \
-d nuyatax.cn -d *.nuyatax.cn \
-d niuyetai.com -d *.niuyetai.com \
-d niuyetai.cn -d *.niuyetai.cn \
-d alitatest.cn -d *.alitatest.cn \
--keypath /etc/ssl/newyetai_all/newyetai_all.key \
--fullchainpath /etc/ssl/newyetai_all/newyetai_all.key.pem \
--reloadcmd "service nginx force-reload"