LoongLee's blog

SSL TLS证书签注

SSL TLS证书签注

来源

原始文档: SSL TLS 证书签注.md

核心内容

SSL/TLS 证书的申请、签注和配置指南。

证书类型

类型 验证级别 适用场景
DV 域名验证 个人站点、博客
OV 组织验证 企业官网
EV 扩展验证 金融、电商

Let's Encrypt免费证书

# 使用 Certbot 申请
sudo apt install certbot

#  standalone 模式
sudo certbot certonly --standalone -d example.com -d www.example.com

# webroot 模式
sudo certbot certonly --webroot -w /var/www/html -d example.com

# nginx 插件
sudo certbot --nginx -d example.com

证书文件说明

/etc/letsencrypt/live/example.com/
├── cert.pem      # 服务器证书
├── chain.pem     # 中间证书链
├── fullchain.pem # 完整证书链(推荐)
└── privkey.pem   # 私钥

自动续期

# 测试续期
sudo certbot renew --dry-run

# 添加到 cron
echo "0 3 * * * /usr/bin/certbot renew --quiet" | sudo crontab -

Nginx 配置

server {
    listen 443 ssl http2;
    server_name example.com;

    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

    # SSL 优化
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
    ssl_prefer_server_ciphers off;
}

查看证书信息

# 查看证书详情
openssl x509 -in cert.pem -text -noout

# 查看过期时间
echo | openssl s_client -servername example.com -connect example.com:443 2>/dev/null | openssl x509 -noout -dates

# 检查证书链
openssl verify -CAfile chain.pem cert.pem

关键要点

  • 使用 fullchain.pem 避免证书链不完整问题
  • TLS 1.2+ 和强密码套件是必须的
  • 配置 HTTP 自动跳转 HTTPS
  • 定期监控证书过期时间

相关实体

  • SSL - 安全套接层
  • TLS - 传输层安全
  • Let's Encrypt - 免费证书颁发机构
  • Certbot - 证书自动化工具
  • HTTPS - HTTP over TLS