Files
calx/gen-cert.sh
2026-07-18 16:48:41 +08:00

13 lines
606 B
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
# 生成/更新自签名 HTTPS 证书IP 变了就重新跑一次)
cd "$(dirname "$0")"
mkdir -p certs
IP=$(ipconfig getifaddr en0 2>/dev/null || ipconfig getifaddr en1 2>/dev/null || echo 127.0.0.1)
echo "为本机 IP = $IP 生成自签名证书..."
openssl req -x509 -newkey rsa:2048 -nodes \
-keyout certs/key.pem -out certs/cert.pem -days 825 \
-subj "/CN=calx-local" \
-addext "subjectAltName=IP:${IP},IP:127.0.0.1,DNS:localhost"
openssl x509 -in certs/cert.pem -outform der -out certs/calx-cert.cer
echo "完成。iOS 请访问 https://${IP}:8443/cert 下载并信任证书。"