Skip to content

crypto/x509: can set pathlen in certificate when not CA #38216

Description

@m-j-jam

RFC 5280 prohibits setting path lengths when not a CA.
From section 4.2.1.9

CAs MUST NOT include the pathLenConstraint field unless the cA
boolean is asserted and the key usage extension asserts the
keyCertSign bit.

This isn't restricted by the library, and means you can create invalid certificates. These are now failing checks in the latest version of OpenSSL (openssl/openssl#11456)

The relevant code is around

ret[n].Value, err = asn1.Marshal(basicConstraints{template.IsCA, maxPathLen})

Something like
if !template.IsCA {
maxPathLen = -1
}
would probably fix, but I'm not an expert in either Go or security, so don't want to change critical code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions