30 lines
1.3 KiB
Bash
30 lines
1.3 KiB
Bash
#!/bin/bash
|
||
# Jarvis 证书申请与安装(acme.sh + 腾讯云 DNS)
|
||
# 用法:上传到服务器后 chmod +x refresh_jarvis_cert.sh && ./refresh_jarvis_cert.sh
|
||
# 若报 $'\r': command not found,先执行:sed -i 's/\r$//' refresh_jarvis_cert.sh
|
||
|
||
set -e
|
||
cd /root/project/acme/acme.sh
|
||
|
||
# 1. 申请/续期证书(--force 强制续期;ECC 用 --keylength ec-256)
|
||
# --dnssleep 120:添加 TXT 后等 2 分钟再让 CA 校验,避免「retryafter too large」因 DNS 未生效
|
||
./acme.sh --dns dns_tencent --issue \
|
||
-d jarvis.van333.cn -d van333.cn \
|
||
--keylength ec-256 \
|
||
--dnssleep 120 \
|
||
--force \
|
||
--debug 2
|
||
|
||
# 2. 安装证书(--ecc 必须紧跟在 -d 域名后,避免 Unknown parameter)
|
||
./acme.sh --install-cert -d jarvis.van333.cn --ecc \
|
||
--key-file /opt/1panel/apps/openresty/openresty/www/common/ssl/jarvis.van333.cn.key \
|
||
--fullchain-file /opt/1panel/apps/openresty/openresty/www/common/ssl/jarvis.van333.cn/fullchain.cer \
|
||
--reloadcmd "docker restart openresty"
|
||
|
||
# 3. 验证
|
||
echo "--- 证书文件 ---"1
|
||
ls -l /opt/1panel/apps/openresty/openresty/www/common/ssl/
|
||
ls -l /opt/1panel/apps/openresty/openresty/www/common/ssl/jarvis.van333.cn/ 2>/dev/null || true
|
||
echo "--- 证书过期时间 ---"
|
||
openssl x509 -in /opt/1panel/apps/openresty/openresty/www/common/ssl/jarvis.van333.cn/fullchain.cer -noout -enddate 2>/dev/null || true
|