X509V3_EXT_PRINT(3)

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

πŸ’… X509V3_EXT_PRINT(3) β€” bestie edition

okay so this is the page for X509V3_EXT_print and X509V3_EXT_print_fp from the libcrypto library manual β€” yes, that libcrypto β€” and we're gonna pretty-print an X.509 extension together. grab a strawberry drink, this is actually so fun πŸ“βœ¨


✨ NAME ✨

X509V3_EXT_print, X509V3_EXT_print_fp β€” pretty-print an X.509 extension πŸ’…

🌸 SYNOPSIS 🌸

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

int
X509V3_EXT_print(BIO *bio, X509_EXTENSION *ext, unsigned long flags,
    int indent);

int
X509V3_EXT_print_fp(FILE *file, X509_EXTENSION *ext, int flags,
    int indent);

πŸ¦‹ DESCRIPTION πŸ¦‹

so X509V3_EXT_print() and X509V3_EXT_print_fp() both take ext, decode it, and print the data inside it β€” to the bio or the file respectively β€” in a human-readable format, with a left margin of indent space characters. 🫢

and like, the details of both the decoding and the printing depend on the type of ext. no cap.

πŸŽ€ the decoding situation

for most extension types, the decoding is done the exact same way it would be done by the appropriate public API function, for example:

πŸ‘‘ the printing situation

for some types, the printing is performed by a dedicated non-public function built into the library. for some other types, the printing function is a public API function, for example:

ngl, some of the public printing functions are not documented yet. 😭 (it's giving "we'll get to it", and honestly? same.)

🧚 the unknown / broken extension lore

if ext is of an unknown extension type, or if decoding fails while using the decoding function for the relevant type, the action taken depends on the flags argument:

  • If the bit X509V3_EXT_PARSE_UNKNOWN is set, ASN1_parse_dump(3) is called on the BER-encoded data of the extension, passing -1 for the dump argument. so like, some info about the encoding of the extension gets printed and some about its decoded content, falling back to BIO_dump_indent(3) for the decoded content unless a dedicated printing method is known for the respective data type(s). and note β€” even if an extension type is unknown, the data type used by the unknown extension, or, if that data type is constructed, of the values contained in it, may still be known, which may allow printing the content of even an unknown extension in a structured or partially structured form. slay, honestly. ✨
  • If the bit X509V3_EXT_DUMP_UNKNOWN is set, BIO_dump_indent(3) is called on the BER-encoded data of the extension without decoding it first, which is usually less readable than the above but poses a smaller risk of omitting or misrepresenting parts of the information.
  • If the bit X509V3_EXT_ERROR_UNKNOWN is set, only the fixed string "<Not Supported>" is printed for an unknown type, or only the fixed string "<Parse Error>" if the parsing function fails β€” but printing is considered as successful anyway. πŸ™ˆ
  • If more than one of these three bits is set, or if a bit in X509V3_EXT_UNKNOWN_MASK is set that is not listed above, nothing is printed, but printing is considered as successful anyway.
  • If none of the bits in X509V3_EXT_UNKNOWN_MASK are set, nothing is printed and printing is considered as failed.
πŸ’€ lowkey the mask logic is the main character here, k? read it twice, iykyk.

⭐ RETURN VALUES ⭐

X509V3_EXT_print() and X509V3_EXT_print_fp() return 0 if failure was both detected and considered relevant. otherwise, 1 is returned β€” and in general the user cannot tell whether failure simply went undetected, whether the function detected failure but regarded it as irrelevant, or whether printing did indeed succeed. 😭 yeah. it's that kind of vibe check.

🌈 SEE ALSO 🌈

πŸ’œ HISTORY πŸ’œ

these functions first appeared in OpenSSL 0.9.2 and have been available since OpenBSD 2.6. iconic longevity behavior, fr fr. πŸ‘‘

πŸ”₯ BUGS πŸ”₯

these functions lack error handling throughout. when a write operation fails, they will usually ignore the fact that information was omitted from the output and report success to the caller anyway. 🫠

🚨 for real though β€” that's a real caveat, not just me being dramatic. write fails, info goes missing, function still says "we're so good". watch out.

and that's the page, bestie πŸŽ€ this one's from the Debian build of the manual, dated June 8, 2025 β€” X509V3_EXT_PRINT(3), signing off πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from