X509_REQ_GET_ATTR(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… X509_REQ_GET_ATTR πŸ’…

okay so this is the 3ossl manual page, bestie β€” it's all about X509_ATTRIBUTE support for signed certificate requests, and honestly? it's giving "deep magic but make it cute". let's get into it πŸŽ€


✨ NAME ✨

X509_REQ_get_attr_count, X509_REQ_get_attr_by_NID, X509_REQ_get_attr_by_OBJ, X509_REQ_get_attr, X509_REQ_delete_attr, X509_REQ_add1_attr, X509_REQ_add1_attr_by_OBJ, X509_REQ_add1_attr_by_NID, X509_REQ_add1_attr_by_txt β€” literally all the X509_ATTRIBUTE support you need for signed certificate requests πŸ¦‹


✨ SYNOPSIS ✨

like, here's the whole squad:

#include <openssl/x509.h>

int X509_REQ_get_attr_count(const X509_REQ *req);
int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos);
int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj,
                             int lastpos);
X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
                              const ASN1_OBJECT *obj, int type,
                              const unsigned char *bytes, int len);
int X509_REQ_add1_attr_by_NID(X509_REQ *req,
                              int nid, int type,
                              const unsigned char *bytes, int len);
int X509_REQ_add1_attr_by_txt(X509_REQ *req,
                              const char *attrname, int type,
                              const unsigned char *bytes, int len);

🌸 DESCRIPTION 🌸

🧚 the "find me" girlies

  • X509_REQ_get_attr_by_OBJ() β€” this one finds the location of the first matching object obj in the req attribute list. the search starts at the position after lastpos. and here's the slay part: if the returned value is positive, you can feed it right back in on the next call to X509_REQ_get_attr_by_OBJ() as the value of lastpos so you can iterate through all the remaining attributes πŸ”. on that very first call, lastpos can be set to any negative value to start searching from the start of the attribute list. iykyk.
  • X509_REQ_get_attr_by_NID() β€” same energy as X509_REQ_get_attr_by_OBJ(), except it passes the numerical identifier (NID) nid associated with the object instead 🏷️. peep <openssl/obj_mac.h> for the full list of NID_*.
  • X509_REQ_get_attr() β€” hands you the X509_ATTRIBUTE object at index loc in the req attribute list. loc should be in the range from 0 to X509_REQ_get_attr_count() - 1. no off-by-one shenanigans, bestie πŸ™ˆ

πŸ’€ the "bye bye" one

  • X509_REQ_delete_attr() β€” removes the X509_ATTRIBUTE object at index loc in the req object's list of attributes. an error occurs if req is NULL. like, obviously πŸ’…

πŸ‘‘ the "add it, add it now" girlies

  • X509_REQ_add1_attr() β€” pushes a copy of the passed-in X509_ATTRIBUTE attr to the req object's attribute list. an error will occur if either the attribute list is NULL or the attribute already exists 🚫
  • X509_REQ_add1_attr_by_OBJ() β€” creates a brand-new X509_ATTRIBUTE using X509_ATTRIBUTE_set1_object() and X509_ATTRIBUTE_set1_data() to assign a new obj with type type and data bytes of length len, and then pushes it to the req object's attribute list. req must be non-NULL or an error will occur. and if obj already exists in the attribute list, that's an error too ✨
  • X509_REQ_add1_attr_by_NID() β€” same as X509_REQ_add1_attr_by_OBJ(), except it passes the numerical identifier (NID) nid associated with the object 🏷️. check <openssl/obj_mac.h> for the list of NID_*.
  • X509_REQ_add1_attr_by_txt() β€” same as X509_REQ_add1_attr_by_OBJ(), except it passes a name attrname associated with the object πŸ“›. see <openssl/obj_mac.h> for the list of SN_* names.
also, real talk: refer to X509_ATTRIBUTE(3) for all the info related to attributes, k? 🫢

πŸ”₯ RETURN VALUES πŸ”₯

  • X509_REQ_get_attr_count() β€” returns the number of attributes in the req object attribute list, or -1 if the attribute list is NULL. vibe check: -1 means bad news 😭
  • X509_REQ_get_attr_by_OBJ() β€” returns -1 if either the req object's attribute list is empty OR obj is not found. otherwise it returns the location of the obj in the attribute list. periodt.
  • X509_REQ_get_attr_by_NID() β€” same as X509_REQ_get_attr_by_OBJ(), except it returns -2 if the nid is not known by OpenSSL. two whole negative numbers, we love a specific queen πŸ’…
  • X509_REQ_get_attr() β€” returns either an X509_ATTRIBUTE or NULL on error.
  • X509_REQ_delete_attr() β€” returns either the removed X509_ATTRIBUTE or NULL if there is an error.
  • X509_REQ_add1_attr(), X509_REQ_add1_attr_by_OBJ(), X509_REQ_add1_attr_by_NID() and X509_REQ_add1_attr_by_txt() β€” return 1 on success or 0 on error. cute and simple πŸŽ€

⭐ NOTES ⭐

any functions that modify the attributes (add or delete) internally set a flag to indicate the ASN.1 encoding has been modified. so like, they know they changed stuff and they're not being sneaky about it πŸ™ˆβœ¨


🌈 SEE ALSO 🌈

X509_ATTRIBUTE(3) β€” go read that one too, bestie 🫢


Copyright 2023-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 version 3.5.0, dated 2026-09-25, and it's the X509_REQ_GET_ATTR(3ossl) manual β€” go forth and slay those attributes πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from