我有多个域的自签名证书(假设是 my.foo.bar.com 和 yours.foo.bar.com),我已使用 Keychain Access 导入该证书,但 Chrome 仍然不接受它,在每个域每次浏览 session 开始时提示我进行验证。
证书是使用 x509v3 主题备用名称扩展生成的,用于验证多个域。如果我在导入证书之前导航到该网站,我会收到与导入后不同的警告消息。下面附上两个错误的图片(上面是导入之前的错误)
有什么方法可以接受自签名多域证书吗?顺便说一句,我只在 Chrome 中收到警告。 FF 和 Safari 工作得很好(除了那些浏览器很糟糕;))
更新:我尝试使用 openssl cli 和 xca 生成证书图形用户界面
最佳答案
问题在于您尝试使用太宽泛的通配符(*
或 *.com
)。
规范( RFC 6125 和 RFC 2818 Section 3.1 )讨论“最左边”标签,这意味着应该有多个标签:
1. The client SHOULD NOT attempt to match a presented identifier in which the wildcard character comprises a label other than the left-most label (e.g., do not match bar.*.example.net). 2. If the wildcard character is the only character of the left-most label in the presented identifier, the client SHOULD NOT compare against anything but the left-most label of the reference identifier (e.g., *.example.com would match foo.example.com but not bar.foo.example.com or example.com).
我不确定是否有规范规定最少应该有多少个标签,但Chromium code表示必须至少有 2 个点:
We required at least 3 components (i.e. 2 dots) as a basic protection against too-broad wild-carding.
这确实是为了防止像 *.com
这样的过于宽泛的情况。这可能看起来不方便,但 CA 偶尔会犯错误,并且采取措施防止向 *.com
颁发的潜在流氓证书发挥作用并不一定是坏事。
如果我没记错的话,某些实现比这更进一步,并且具有对于二级域来说也太宽泛的列表域(例如 .co.uk
)。
关于第二个示例:“CN:bar.com, SAN: DNS:my.foo.bar.com, DNS:yours.foo.bar.com”。此证书应对 my.foo.bar.com
和 yours.foo.bar.com
有效,但对 bar.com
无效。 CN 仅是不存在 SAN 时的后备解决方案。如果存在任何 SAN,则应忽略 CN(尽管某些实现会更宽容)。
关于google-chrome - Mac OS X - 接受自签名多域 SSL 证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15907081/