超出自签名证书路径限制

Self signed certificate path constraint exceeded

我有以下自签名证书链:

RootCA -> IntermediateCA(由 root 签名)-> Server Cert(TLS 叶,由中间签名)

RootCA 的 MaxPathLen = 0

我的证书是使用 CreateCertificateAuthorityCreateIntermediateCertificateAuthority 使用 certstrap 生成的,所以我假设默认设置是正确的。但是当我试图让我的自签名证书与 Python 或 Node 客户端一起工作时,我遇到了 path length constraint exceeded 错误。

NOTE: The setup was working fine when using a Go TLS client by just supplying the intermediate CA certificate. Python and Node seem to require the full cert chain hence why the problem arose.

来自rfc5280我看到的说法是:

In this case, it gives the maximum number of non-self-issued intermediate certificates that may follow this certificate in a valid certification path.

我对 non-self-issued intermediate certificates 感到困惑。这是否意味着我的链是有效的,因为 RootCA 签署了中间(因此它是 not 非自发)。或者它无效,因为中间件算作 non-self-issued 证书。这里的 self 到底指的是什么?它可以是自签名或 rootca 是自签名的。

在这种情况下,我的 rootCA 实际上应该有 1 的 MaxPathLen 吗?

如果根有一个MaxPathLen=0,那么它只能颁发最终实体证书,不能跟随着中间CA证书。根 CA 是自签名的。

在您的情况下,Root 已颁发中间 CA,这是不允许的。并且会得到你描述的错误。

non-self-issued intermediate certificates

这指的是可以跟随由根颁发的根的中间 CA。

Or it is not valid, because the intermediate counts as as a non-self-issued certificate.

中间值超过 MaxPathlen = 0 是正确的。

Self

指根。

Root CA and maxPathLen

具有 maxPathLen >= 1 的根 CA 将适用于所呈现的场景。它可以有一个中间 CA,并且该中间可以签署最终实体证书。

Root -> ICA -> EE

然而,如果 maxPathLen=1,以下将不起作用:

Root -> ICA-1 -> ICA-2 -> EE

self-issued是指链中的一个证书是发给自己的——也就是Subject和Issuer是一样的。这通常用于密钥转换目的,否则可以忽略。

您的问题出现是因为您将 0 的 basicConstraint pathLenConstraint 放在 Root 上。值为 0 时,它应该位于链中的最后一个 CA - 您称为中间 CA 的那个。

来自 RFC 5280:

A pathLenConstraint of zero indicates that no [non- self-issued] intermediate CA certificates may follow in a valid certification path

明智的做法是不要在您的 Root 上使用 pathLenConstraint,因为您在签署时可能不知道您的从属 CA 将如何随着时间的推移而填充。