X509_ACERT_GET_ATTR(3ossl)

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

🌸 X509_ACERT_GET_ATTR(3ossl) β€” bestie's guide to pulling attributes out of an X509_ACERT 🌸

okay so this is the 3ossl manual page, and it's literally about getting attributes out of an attribute certificate. yes, the whole vibe is "i have an X509_ACERT and i need to know what's inside it." it's giving detective energy πŸ”πŸ’…


✨ NAME ✨

X509_ACERT_get_attr, X509_ACERT_get_attr_by_NID, X509_ACERT_get_attr_by_OBJ, X509_ACERT_get_attr_count β€” retrieve attributes from an X509_ACERT structure. that's the whole job, and they ate 🫢


πŸŽ€ SYNOPSIS πŸŽ€

like, just include the header first, obviously:

#include <openssl/x509_acert.h>

then here's the whole squad:

X509_ATTRIBUTE *X509_ACERT_get_attr(const X509_ACERT *x, int loc);
int X509_ACERT_get_attr_by_NID(const X509_ACERT *x, int nid, int lastpos);
int X509_ACERT_get_attr_by_OBJ(const X509_ACERT *x, const ASN1_OBJECT *obj,
                               int lastpos);
int X509_ACERT_get_attr_count(const X509_ACERT *x);

πŸ’– DESCRIPTION πŸ’–

so X509_ACERT_get0_attr() retrieves the locth X509_ATTRIBUTE from an X509_ACERT x. (and yeah, the synopsis spells it X509_ACERT_get_attr while the prose says X509_ACERT_get0_attr β€” not me fixing that, we're keeping it exactly as the page says it, no cap πŸ’€)

X509_ACERT_get_attr_count() returns the total number of attributes in the X509_ACERT. it's the headcount, the attendance sheet, the "how many are we even dealing with" function ✨

X509_ACERT_get_attr_by_NID() and X509_ACERT_get_attr_by_OBJ() retrieve the next attribute location matching nid or obj after lastpos.

🚨 bestie listen: lastpos should initially be set to -1. start there or you're gonna have a bad time.

if there are no more entries, -1 is returned. and if nid is invalid (like, doesn't correspond to a valid OID), then -2 is returned. two different negative numbers, two different moods 😭


🌈 RETURN VALUES 🌈

okay so what do you actually get back:

  • X509_ACERT_get0_attr() returns an X509_ATTRIBUTE from an attribute certificate, or NULL if the specified attribute is not found. not found = NULL, simple as that πŸ™ˆ
  • X509_ACERT_get_attr_by_NID() and X509_ACERT_get_attr_by_OBJ() return the location of the next attribute requested, or -1 if not found. and X509_ACERT_get_attr_by_NID() can also return -2 if the supplied NID is invalid. she contains multitudes πŸ’…
  • X509_ACERT_get_attr_count() returns the number of attributes in the given attribute certificate. a number. a plain little number. iconic πŸ‘‘

πŸ¦‹ HISTORY πŸ¦‹

X509_ACERT_get0_attr(), X509_ACERT_get_attr_by_NID(), X509_ACERT_get_attr_by_OBJ() and X509_ACERT_get_attr_count() were added in OpenSSL 3.4. so they're new-new, freshly added, main character debut energy ⭐


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 page, bestie 🫢 version 3.5.0, dated 2026-09-25, manual X509_ACERT_GET_ATTR(3ossl) β€” go forth and get those attributes πŸ’œπŸŽ€

πŸ“¦ where this page comes from