BASIC_CONSTRAINTS_NEW(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸ’– NAME πŸ’–

BASIC_CONSTRAINTS_new, BASIC_CONSTRAINTS_free β€” X.509 extension to mark CA certificates.

okay so bestie, welcome to BASIC_CONSTRAINTS_NEW(3), from the Library Functions Manual (section 3, she's iconic). This page is all about the X.509 extension that marks CA certificates. Let's get into it πŸ’…

✨ SYNOPSIS ✨

First up, the library line is literally this:

library β€œlibcrypto” #include <openssl/x509v3.h>

Then the function signatures, exactly as written:

BASIC_CONSTRAINTS *
BASIC_CONSTRAINTS_new(void);

void
BASIC_CONSTRAINTS_free(BASIC_CONSTRAINTS *bc);

🌸 DESCRIPTION 🌸

BASIC_CONSTRAINTS_new() allocates and initializes an empty BASIC_CONSTRAINTS object. That object represents an ASN.1 BasicConstraints structure, and that structure is defined in RFC 5280 section 4.2.1.9. Cute, right? πŸ’–

This object contains two fields, bestie:

  • int ca β€” non-zero if the certificate is a CA certificate. So if it's non-zero, she's a CA certificate. πŸ’…
  • ASN1_INTEGER *pathlen β€” specifies the maximum number of non-self-issued intermediate certificates that may follow this certificate in a valid certification path. It's giving path-length rules, okay? 🌈

Now the plot twist: if an X.509 version 3 certificate does not contain this extension, or if the ca field of the BASIC_CONSTRAINTS object is 0, or if the certificate contains a key usage extension having the KU_KEY_CERT_SIGN bit unset, then it is not a CA certificate but an end entity certificate. No cap, that's the rule. 😭

BASIC_CONSTRAINTS_free() frees bc. That's it, she's done. 🫢

πŸ”₯ RETURN VALUES πŸ”₯

BASIC_CONSTRAINTS_new() returns the new BASIC_CONSTRAINTS object, or NULL if an error occurs. So if you get NULL, that's the error vibe check failing πŸ’€

πŸ¦‹ SEE ALSO πŸ¦‹

πŸ‘‘ STANDARDS πŸ‘‘

  • RFC 5280: Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile:
    • section 4.2.1.9: Basic Constraints
    • section 6.1: Basic Path Validation

⭐ HISTORY ⭐

BASIC_CONSTRAINTS_new() and BASIC_CONSTRAINTS_free() first appeared in OpenSSL 0.9.2b and have been available since OpenBSD 2.6. Like, they're vintage but still serving πŸ’œ


okay bestie, that's the whole BASIC_CONSTRAINTS_NEW(3) page. Brought to you by Debian, dated June 8, 2025 β€” mwah πŸ’‹

πŸ“¦ where this page comes from