X509_REQ_GET_ATTR(3ossl)
π 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 objectobjin thereqattribute list. the search starts at the position afterlastpos. and here's the slay part: if the returned value is positive, you can feed it right back in on the next call toX509_REQ_get_attr_by_OBJ()as the value oflastposso you can iterate through all the remaining attributes π. on that very first call,lastposcan 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 asX509_REQ_get_attr_by_OBJ(), except it passes the numerical identifier (NID)nidassociated with the object instead π·οΈ. peep<openssl/obj_mac.h>for the full list ofNID_*.X509_REQ_get_attr()β hands you theX509_ATTRIBUTEobject at indexlocin thereqattribute list.locshould be in the range from0toX509_REQ_get_attr_count() - 1. no off-by-one shenanigans, bestie π
π the "bye bye" one
X509_REQ_delete_attr()β removes theX509_ATTRIBUTEobject at indexlocin thereqobject's list of attributes. an error occurs ifreqisNULL. like, obviously π
π the "add it, add it now" girlies
X509_REQ_add1_attr()β pushes a copy of the passed-inX509_ATTRIBUTEattrto thereqobject's attribute list. an error will occur if either the attribute list isNULLor the attribute already exists π«X509_REQ_add1_attr_by_OBJ()β creates a brand-newX509_ATTRIBUTEusingX509_ATTRIBUTE_set1_object()andX509_ATTRIBUTE_set1_data()to assign a newobjwith typetypeand databytesof lengthlen, and then pushes it to thereqobject's attribute list.reqmust be non-NULLor an error will occur. and ifobjalready exists in the attribute list, that's an error too β¨X509_REQ_add1_attr_by_NID()β same asX509_REQ_add1_attr_by_OBJ(), except it passes the numerical identifier (NID)nidassociated with the object π·οΈ. check<openssl/obj_mac.h>for the list ofNID_*.X509_REQ_add1_attr_by_txt()β same asX509_REQ_add1_attr_by_OBJ(), except it passes a nameattrnameassociated with the object π. see<openssl/obj_mac.h>for the list ofSN_*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 thereqobject attribute list, or-1if the attribute list isNULL. vibe check:-1means bad news π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. periodt.X509_REQ_get_attr_by_NID()β same asX509_REQ_get_attr_by_OBJ(), except it returns-2if thenidis not known by OpenSSL. two whole negative numbers, we love a specific queen π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. 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 π
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
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms