You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1.5 KiB

SSL 证书目录

此目录用于存放 SSL 证书文件。

文件要求

请将以下文件放置在此目录中:

  • cert.pem - SSL 证书文件(或 fullchain.pem
  • key.pem - SSL 私钥文件

获取 SSL 证书

方式 1: 使用 Let's Encrypt (免费)

  1. 安装 certbot:
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install certbot

# 或使用 Docker
docker run -it --rm -v $(pwd)/ssl:/etc/letsencrypt certbot/certbot certonly --standalone
  1. 获取证书后,将证书文件复制到此目录:
# Let's Encrypt 证书通常在 /etc/letsencrypt/live/your-domain.com/
cp /etc/letsencrypt/live/your-domain.com/fullchain.pem ./ssl/cert.pem
cp /etc/letsencrypt/live/your-domain.com/privkey.pem ./ssl/key.pem

方式 2: 使用自签名证书 (仅用于测试)

# 生成自签名证书(仅用于开发测试)
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
  -keyout ssl/key.pem \
  -out ssl/cert.pem \
  -subj "/C=CN/ST=State/L=City/O=Organization/CN=localhost"

方式 3: 使用商业证书

将您购买的 SSL 证书文件重命名为:

  • 证书文件 → cert.pem
  • 私钥文件 → key.pem

文件权限

确保私钥文件权限正确(仅所有者可读):

chmod 600 ssl/key.pem
chmod 644 ssl/cert.pem

注意事项

  • ⚠️ 不要将私钥文件提交到版本控制系统
  • 生产环境请使用有效的 SSL 证书
  • 自签名证书会导致浏览器显示安全警告