PKCS12_ADD1_ATTR_BY_NID(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… PKCS12_add1_attr_by_NID(3ossl) β€” bestie's guide to piling attributes onto a safeBag πŸŽ€

Okay so this is a page from the OpenSSL manual, section 3ossl, and honestly? It's a short one, which is a slay. Sit down, grab a boba, and let's get into it πŸ§‹βœ¨


✨ NAME ✨

PKCS12_add1_attr_by_NID, PKCS12_add1_attr_by_txt β€” the two functions that add an attribute to a PKCS#12 safeBag structure. That's it, that's the whole vibe πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <openssl/pkcs12.h>

int PKCS12_add1_attr_by_NID(PKCS12_SAFEBAG *bag, int nid, int type,
                            const unsigned char *bytes, int len);
int PKCS12_add1_attr_by_txt(PKCS12_SAFEBAG *bag, const char *attrname, int type,
                            const unsigned char *bytes, int len);

Look at them. Twins. Iconic. πŸ‘‘


🌸 DESCRIPTION 🌸

These functions add a PKCS#12 Attribute to the Attribute Set of the bag. Main character energy for your PKCS12_SAFEBAG 🫢

  • PKCS12_add1_attr_by_NID() β€” adds an attribute of type nid with a value of ASN1 type type, constructed using len bytes from bytes.
  • PKCS12_add1_attr_by_txt() β€” adds an attribute of type attrname with a value of ASN1 type type, constructed using len bytes from bytes.

Notice the difference bestie: one takes an nid (a number-y identifier), the other takes an attrname (a text string). Everything else is literally the same. type is your ASN1 type, bytes + len is the raw material, no cap. πŸ’œ


⭐ NOTES ⭐

Heads up, this is the important bit πŸ‘€

These functions do not check whether an existing attribute of the same type is present. There can be multiple attributes with the same type assigned to a safeBag. So like, they will not gatekeep you. Duplicates are allowed. It's giving "no thoughts, just append" πŸ’€

Both functions were added in OpenSSL 3.0 β€” so if you're on some ancient version, that's a no from her πŸ™ˆ


🌈 RETURN VALUES 🌈

  • 1 β€” success, we ate πŸ”₯
  • 0 β€” failure, it's giving flop 😭

That's it. Binary. Two moods.


🐚 SEE ALSO 🐚

PKCS12_create(3) β€” go read that one next, iykyk πŸ’…


Copyright 2020 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>.

Like, actually read the license, bestie β€” it's not decorative ✨


That's the whole page! Version 3.5.6, dated 2026-04-07 β€” mwah, sending you off with a kiss and a PKCS12_add1_attr_by_NID πŸ’‹πŸ¦‹

πŸ“¦ where this page comes from