apisix/ssl_manager/delete_and_renew_cert.sh

51 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 删除旧证书并重新申请生产环境证书
DOMAIN="test.jingrowtools.cn"
echo "=== 删除旧 STAGING 证书 ==="
echo "域名: $DOMAIN"
echo ""
# 删除证书
echo "1. 删除证书..."
certbot delete --cert-name "$DOMAIN" --non-interactive 2>&1
if [ $? -eq 0 ]; then
echo "✅ 证书删除成功"
else
echo "⚠️ 证书删除失败或证书不存在"
fi
echo ""
echo "=== 重新申请生产环境证书 ==="
echo "使用当前配置staging=False重新申请..."
echo ""
# 使用 ssl_manager 重新申请
python3 -c "
from ssl_manager import APISIXSSLManager
mgr = APISIXSSLManager()
print(f'当前配置: staging={mgr.staging}')
print()
if mgr.staging:
print('❌ 警告: 配置仍然是 staging=True')
print('请先修改 ssl_manager.py 中的 letsencrypt_staging=False')
exit(1)
else:
print('✅ 配置正确: staging=False (生产环境)')
print()
print('开始申请证书...')
result = mgr.request_certificate('$DOMAIN')
if result:
print('✅ 证书申请成功!')
else:
print('❌ 证书申请失败')
exit(1)
"
echo ""
echo "=== 完成 ==="