X509_REQ_GET_ATTR(3SSL)
πΈ NAME πΈ
okay bestie, gather round π this is the OpenSSL 3SSL manual page β yes, the whole squad lives here:
X509_REQ_get_attr_countX509_REQ_get_attr_by_NIDX509_REQ_get_attr_by_OBJX509_REQ_get_attrX509_REQ_delete_attrX509_REQ_add1_attrX509_REQ_add1_attr_by_OBJX509_REQ_add1_attr_by_NIDX509_REQ_add1_attr_by_txt
and together they're the X509_ATTRIBUTE support for signed certificate requests. periodt. π
β¨ SYNOPSIS β¨
#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 π
X509_REQ_get_attr_by_OBJ() goes hunting for the location of the first matching object obj in the req attribute list. the search starts at the position after lastpos, okay? and here's the cute part β if the value it hands back is positive, you can totally feed it right back into the next call of X509_REQ_get_attr_by_OBJ() as the value of lastpos and just iterate through all the remaining attributes. slay. π¦ and if you're starting fresh? set lastpos to any negative value on that first call and it'll search from the very start of the attribute list.
X509_REQ_get_attr_by_NID() is giving the same energy as X509_REQ_get_attr_by_OBJ(), except it passes the numerical identifier (NID) nid that's associated with the object. check <openssl/obj_mac.h> for the full list of NID_*. π
X509_REQ_get_attr() returns the X509_ATTRIBUTE object sitting at index loc in the req attribute list. quick vibe check: loc should be somewhere in the range from 0 to X509_REQ_get_attr_count() - 1. no off-by-one shenanigans pls π
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. gone, deleted, not me being dramatic π
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. (yes, we do not do duplicates here bestie, rules are rules.)
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? an error occurs. π
X509_REQ_add1_attr_by_NID() is basically X509_REQ_add1_attr_by_OBJ() but 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() is also basically X509_REQ_add1_attr_by_OBJ(), except it passes a name attrname associated with the object. look at <openssl/obj_mac.h> for the list of SN_* names. π
and for all the tea on attributes in general, refer to X509_ATTRIBUTE(3). π
π₯ RETURN VALUES π₯
X509_REQ_get_attr_count()returns the number of attributes in thereqobject attribute list, or-1if the attribute list isNULL. πX509_REQ_get_attr_by_OBJ()returns-1if either thereqobject's attribute list is empty ORobjis not found. otherwise it returns the location of theobjin the attribute list. πX509_REQ_get_attr_by_NID()is similar toX509_REQ_get_attr_by_OBJ(), except it returns-2if thenidisn't known by OpenSSL. (a whole different number, iconic honestly.) πX509_REQ_get_attr()returns either anX509_ATTRIBUTEorNULLon error.X509_REQ_delete_attr()returns either the removedX509_ATTRIBUTEorNULLif there is an error.X509_REQ_add1_attr(),X509_REQ_add1_attr_by_OBJ(),X509_REQ_add1_attr_by_NID()andX509_REQ_add1_attr_by_txt()return1on success or0on error.
π NOTES π
any function that modifies the attributes β add or delete, both of them β internally sets a flag to indicate that the ASN.1 encoding has been modified. π so like, yeah, the data knows it changed. main character behavior fr fr.
π«Ά SEE ALSO π«Ά
π COPYRIGHT π
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, no cap π§π this was X509_REQ_GET_ATTR(3SSL) from the OpenSSL fam β version 4.0.3, dated 2026-09-29. go forth and handle those attributes, you've got this πβ¨
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms