security Roadmap

安全 / 证书排障专题

安全 / 证书排障专题:聚合 HTTPS 证书过期、证书链不完整、SSL certificate problem、SSH 密钥权限、OpenSSL 证书检测和 TLS 配置等安全运维问题的完整排障路径与命令模板。

证书排障先用 openssl s_client 从外部网络验证线上实际返回的证书,而不是只看服务器上的文件时间戳,certbot 续期成功不等于线上证书已更新,必须 reload Nginx 才能生效。

securityopensslssltlscertificatesshhttps
排障 / 命令11
精选入口4
工具 / 速查4
最近更新2026-07-12

Troubleshooting Path

推荐排障路线图

提交问题 →
  1. 01

    先用 openssl 验证线上证书

    用 openssl s_client -connect <host>:443 -servername <host> 触发 SNI 拿到真实证书,用 openssl x509 -noout -dates -issuer -subject 提取有效期和颁发者。

  2. 02

    再检查证书链和中间证书

    ssl_certificate 必须指向 fullchain.pem(含中间证书),只指向 cert.pem 会导致证书链不完整,部分客户端报错。

  3. 03

    继续排查 SSH 密钥权限

    ~/.ssh 目录权限必须 700,authorized_keys 必须 600,家目录不能被其他用户写,权限不对是 SSH 拒绝的最常见原因。

  4. 04

    最后处理续期和监控

    certbot 续期后必须 reload nginx,配置证书过期监控告警,用 certbot renew --deploy-hook 自动化续期后的 reload。

Before You Change

执行前检查

  • 检查公网 HTTPS 证书时一定带 -servername 触发 SNI,否则多站点可能返回默认证书
  • certbot 续期成功不等于线上已更新,必须 systemctl reload nginx
  • 不要把 sslVerify=false 作为永久配置,应使用正确的 CA 证书路径
  • SSH 排障时确认 ~/.ssh 和 authorized_keys 的权限是否正确

Start Here

优先阅读

Latest Updates

最近更新

All Runbooks

全部相关内容

排障

Certbot 证书自动续期失败排查

Certbot 自动续期 Let's Encrypt 证书失败时,用 certbot renew --dry-run 复现真实错误,覆盖 80 端口 HTTP-01 验证不通、Nginx 未放行 .well-known/acme-challenge、DNS TXT 记录未生效和 certbot.timer 未触发等常见根因。

certbotletsencryptssl
排障

Docker 镜像拉取失败排查:超时、证书和架构不匹配

docker pull 出现 TLS handshake timeout、manifest unknown、no matching manifest 或 x509 unknown authority 时,先按错误文本区分网络、Registry 认证、镜像 tag 不存在或 CPU 架构不匹配,再针对性配置代理、镜像源、docker login 或私有仓库 CA。

dockerimageregistry
排障

Git 保存用户名密码的正确方式

Git 通过 HTTPS 拉代码每次都要输入用户名密码时,配置 credential.helper 选择 store 明文、cache 内存缓存或 Windows 下的 manager 加密存储,SSH 仓库改用密钥认证,避免把密码明文写在 remote URL 里。

gitcredentialpassword
排障

Git SSL certificate problem 解决方法

Git clone/pull 报 SSL certificate problem: unable to get local issuer certificate 时,用 GIT_CURL_VERBOSE=1 打印真实证书链,确认是否走了公司代理,把代理 CA 加入 http.sslCAInfo 或系统信任,避免直接关闭 sslVerify。

gitsslproxy
排障

Nginx 301/302 跳转配置与常见问题

Nginx 配置 HTTP→HTTPS、旧域名迁移或路径重写时,用 return 301 https://example.com$request_uri 做永久跳转、302 做临时跳转,避免 rewrite + if 组合,配合 curl -I -L 验证 Location 头,跳转循环则检查 server 块之间是否互指。

nginx301302
排障

HTTPS 混合内容(Mixed Content)排查

HTTPS 页面加载 http:// 资源被浏览器提示 Mixed Content blocked 时,用 F12 Console 定位被阻止的 script/stylesheet/image,区分 active/passive 混合内容并逐个改成 https 或相对协议,也可在 Nginx 加 CSP upgrade-insecure-requests 兜底。

nginxhttpsmixed-content
排障

Nginx HTTPS 证书过期与链不完整排查

浏览器提示 NET::ERR_CERT_DATE_INVALID、curl 返回 SSL certificate problem: certificate has expired 时,用 openssl s_client -connect 查线上实际证书 dates,再对比服务器文件、确认 ssl_certificate 指向 fullchain.pem 且 certbot 续期后 reload 了 Nginx。

nginxsslhttps
排障

SSH Permission denied (publickey) 排查流程

ssh 或 git 拉代码报 Permission denied (publickey) 时,先用 ssh -vvv 看客户端提交了哪把 key 和服务端 Authentications that can continue,再核对 authorized_keys 内容、~/.ssh 目录 700 与 authorized_keys 600 权限,云服务器还要检查 sshd_config 和安全组。

sshpublickey权限
命令

Git 配置和取消代理命令

Git 配置和取消 HTTP/HTTPS/SOCKS5 代理的常用命令,git config --show-origin --get-regexp proxy 找出代理配置来自 system/global/local 哪一级,http.proxy 只影响 HTTP 仓库,SSH 仓库需要单独配置 ssh ProxyCommand 或 IdentityFile。

gitproxyconfig
命令

openssl 检查 HTTPS 证书命令

openssl s_client 检查线上 HTTPS 证书的常用命令,openssl s_client -connect example.com:443 -servername 触发 SNI 拿到真实证书,用 openssl x509 -noout -dates -issuer -subject 提取有效期与颁发者,-showcerts 查看完整证书链。

opensslsslhttps
命令

SSH 生成密钥和分发公钥命令

SSH 生成密钥与分发公钥的常用命令,ssh-keygen -t ed25519 生成推荐算法密钥,ssh-copy-id 一键分发公钥到 authorized_keys,配合 ~/.ssh 700、authorized_keys 600 权限,多账号在 ~/.ssh/config 里用 Host + IdentityFile 区分。

sshkeygenauthorized_keys