为什么不信任有效的中间 x509 证书?

why don't trust valid intermediate x509 certificates?

   A
  / \
 B   C
 |   |
 D   E

当 E(或 C)验证 D 的证书时,他也需要信任 B。 有没有办法避免必须将 B 的证书显式添加到 E 的 CA 存储?

使用 openssl,有没有办法自动从客户端或其他来源(可能是 D 证书中的 issuerDistributionPoint 之类的字段)检索 B 的证书?

is there a way to avoid having to explicitly add B's cert to E's CA store?

常见的方法是在 TLS 握手中将所有中间证书与叶证书一起发送。例如,如果您连接到 google.com,您将获得服务器在 TLS 握手中提供的以下证书链:

 0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=*.google.com
 1 s:/C=US/O=Google Inc/CN=Google Internet Authority G2
 2 s:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA

然后,客户端可以使用中间证书 (1,2) 构建从叶证书 (0) 到本地存储的受信任 CA(在本例中为 /C=US/O=Equifax/OU=Equifax Secure Certificate Authority)的信任链。

当然,您也可以将中间证书添加为客户端中的受信任证书。但是由于有更多的证书也比受信任的根证书更频繁地更改,因此您需要更多的内存,但您也需要使用新的中间证书定期更新您的客户端。

using openssl, is there the way to automate the retrieval of B's cert either from the client or another source (maybe a field like issuerDistributionPoint in D's certificate)?

openssl 不提供特定的工具来处理这个问题。桌面浏览器 Google Chrome 实际上会尝试从 Internet 下载丢失的中间证书,可能基于证书的授权信息访问部分中的信息。但我不知道其他浏览器(除了 Opera 等其他 Chromium 衍生产品)这样做。