doctor-gateway-tls.sh 1.1 KB

12345678910111213141516171819202122232425
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. SNI="${SEOH_GATEWAY_SNI:-api-gateway.dev.seoh.local}"
  4. DEPLOY="${SEOH_DEPLOY_ROOT:-/Users/chengang/Documents/surkw/产品/seoh/seoh-deploy}"
  5. cur=$(echo | timeout 8 openssl s_client -connect 127.0.0.1:3000 -servername "$SNI" 2>/dev/null \
  6. | openssl x509 -noout -subject 2>/dev/null || true)
  7. echo "网关当前出示: ${cur:-<握手失败>}"
  8. if printf '%s' "$cur" | grep -q "CN *= *${SNI}"; then
  9. echo "✅ 证书匹配,无需处理"; exit 0
  10. fi
  11. echo "❌ 未出示对外证书(C1),执行自愈…"
  12. cd "$DEPLOY"
  13. python3 scripts/enable-gateway-external-tls.py --root "$DEPLOY"
  14. docker compose -p seoh-deploy restart api-gateway
  15. for _ in $(seq 1 10); do
  16. sleep 3
  17. [ "$(curl -sk -m 4 -o /dev/null -w '%{http_code}' https://localhost:3000/health)" = "200" ] && break
  18. done
  19. echo "=== 严格校验(证书链 + 主机名)==="
  20. curl -sS --cacert deploy-data/ca-dev/external-edge/root-ca.crt -m 8 -o /dev/null -w "HTTP=%{http_code}\n" \
  21. -X POST "https://${SNI}:3000/api/system/seoh-identity-provider/otp/captcha/create@v1" \
  22. -H 'Content-Type: application/json' -d '{"data":{"channel":"captcha","scene":"playground"}}'