X509_REQ_GET_EXTENSIONS(3ossl)

πŸ’– X509_REQ_GET_EXTENSIONS πŸ’–

okay bestie, gather round, because we're about to talk about X509_REQ_get_extensions, X509_REQ_add_extensions, and X509_REQ_add_extensions_nid β€” the trio that handles the X.509 extension attributes of a CSR πŸŽ€

(this is from the 3ossl manual, OpenSSL's own lil corner of the docs, iykyk ✨)


✨ SYNOPSIS ✨

#include <openssl/x509.h>

STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(const X509_REQ *req);
int X509_REQ_add_extensions(X509_REQ *req, const STACK_OF(X509_EXTENSION) *exts);
int X509_REQ_add_extensions_nid(X509_REQ *req,
                                const STACK_OF(X509_EXTENSION) *exts, int nid);

like, just three lil functions, no big deal πŸ’…


🌸 DESCRIPTION 🌸

X509_REQ_get_extensions()

she returns the first list of X.509 extensions she can find in the attributes of req πŸ¦‹

if there are literally no such extensions in req? the returned list is just empty. no drama, no tears. πŸ’œ

⚠️ okay but listen β€” the caller is responsible for freeing the list obtained. that's you. you're the caller. it's giving "you break it you buy it" but for memory. no cap. 🫢

X509_REQ_add_extensions_nid()

this one adds a list of X.509 extensions exts to req, using nid to identify the extensions attribute ✨

  • if exts is NULL, or it's an empty list β†’ req is unchanged. she said "not today" πŸ’€
  • you can call this function more than once on the same req and nid! in that case any previous extensions get augmented β€” and here's the tea: if an extension you're adding has the same OID as one that's already there, the new one replaces the earlier one πŸ‘‘

X509_REQ_add_extensions()

she's exactly like X509_REQ_add_extensions_nid() except that the default NID_ext_req is used πŸŽ€

simple. iconic. no notes. 🌈


⭐ RETURN VALUES ⭐

  • X509_REQ_get_extensions() β€” returns a pointer to STACK_OF(X509_EXTENSION), or NULL on error 😭
  • X509_REQ_add_extensions() and X509_REQ_add_extensions_nid() β€” return 1 on success, 0 on error πŸ’€

so like, check your return values bestie. NULL and 0 are not the vibe. πŸ”₯


Copyright 2022-2024 The OpenSSL Project Authors. All Rights Reserved. πŸ’–

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that's the whole page, bestie!! 🧚 this was OpenSSL 3.5.9, dated 2026-09-29, filed under X509_REQ_GET_EXTENSIONS(3ossl) β€” mwah, go forth and handle those CSR extension attributes responsibly πŸ’…βœ¨πŸ“

πŸ“¦ where this page comes from