安装acme.sh
安装 acme.sh 并设置邮箱用来接受重要通知,如证书快过期未更新通知
curl https://get.acme.sh | sh -s email=my@example.com
申请证书
Zerossl
相关文章:
从 acme.sh v3.0 说说 ZeroSSL
Zerossl官网
HTTP方式
修改 nginx.conf 配置文件
server {
listen 80;
#请填写绑定证书的域名
server_name example.com;
}
申请证书,–day 2 表示更新证书的天数,默认值为 60 天
acme.sh --issue -d xh123.cn --nginx --days 2
进入~/.acme.sh 目录下,查看证书信息
手动 DNS 方式
手动 DNS 验证
acme.sh --issue -d example.com -d "*.example.com" --dns \
--yes-I-know-dns-manual-mode-enough-go-ahead-please
到 DNS 解析中,新增一条 TXT 记录,域名前缀为 _acme-challenge,记录值为终端输出的 TXT value 的值。然后再次执行
acme.sh --renew -d example.com -d "*.example.com" \
--yes-I-know-dns-manual-mode-enough-go-ahead-please
DNS API 方式
登录腾讯云 DNSPod并创建DNSPos Token 秘钥
获取到秘钥后,在 ~/.acme.sh 目录下的 account.conf 配置文件中添加配置
# 腾讯云
export DP_Id="YourId"
export DP_Key="YourToken"
申请证书,–server letsencrypt 表示指定证书申请服务器为 Let’s Encrypt,–day 2 表示更新证书的天数,默认值为 60 天
acme.sh --issue --server letsencrypt --dns dns_dp -d example.com --days 2
安装证书
acme.sh --install-cert -d example.com \
--key-file /etc/nginx/conf/ssl/example.com/example.com.key \
--fullchain-file /etc/nginx/conf/ssl/example.com/fullchain.cer \
--reloadcmd "systemctl force-reload nginx"
nginx.conf 配置证书信息
server {
#SSL 默认访问端口号为 443
listen 443 ssl;
#请填写绑定证书的域名
server_name example.com;
#请填写证书文件的相对路径或绝对路径
ssl_certificate /etc/nginx/conf/ssl/example.com/fullchain.cer;
#请填写私钥文件的相对路径或绝对路径
ssl_certificate_key /etc/nginx/conf/ssl/example.com/example.com.key;
location / {
root /etc/nginx/html/blog;
index index.html index.htm;
}
}
重启nginx后生效
nginx -c /etc/nginx/nginx.conf
nginx -s reload
使用https方式访问域名网站,查看证书信息
其他命令
查看申请的证书
acme.sh --list
强制续期证书
acme.sh --renew -d example.com --force
删除证书
删除证书
acme.sh --remove -d example.com
撤销证书
acme.sh --revoke -d example.com
命令执行成功后,需要一并删除在~/.acme.sh目录中的域名文件夹
rm -rf example.com_ecc
更新 acme.sh
手动升级 acme.sh 到最新版
acme.sh --upgrade
如果你不想手动升级,可以开启自动升级:
acme.sh --upgrade --auto-upgrade
你也可以随时关闭自动更新:
acme.sh --upgrade --auto-upgrade 0
本文参考链接:
acme.sh-实现自动化部署SSL证书(有详细的 DNS API)
Let’s Encrypt SSL 泛域名证书申请和配置
nginx 配置 acme.sh