PKCS12_ADD1_ATTR_BY_NID(3ossl)

πŸ’– PKCS12_ADD1_ATTR_BY_NID β€” bestie edition πŸ’–

ok so we're in the 3ossl manual, and today's episode is all about PKCS12_add1_attr_by_NID and PKCS12_add1_attr_by_txt. yes the name is long. yes it's giving "I was named by a committee." we move. πŸŽ€


✨ NAME ✨

PKCS12_add1_attr_by_NID, PKCS12_add1_attr_by_txt β€” adding an attribute to a PKCS#12 safeBag structure. that's the whole job. that's the gig. πŸ’…


🌸 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);

πŸ¦‹ DESCRIPTION πŸ¦‹

ok so picture this: you've got a bag. a safeBag. and these two functions? they add a PKCS#12 Attribute to that bag's Attribute Set. simple as. 🫢

  • PKCS12_add1_attr_by_NID() β€” adds an attribute whose type is nid, with a value of ASN1 type type, and that value gets constructed using len bytes pulled from bytes.
  • PKCS12_add1_attr_by_txt() β€” same vibe, but the attribute type is attrname instead of a nid. value is still ASN1 type type, still built from len bytes of bytes.

like. they're siblings. one takes a nid, one takes a txt. iconic behavior honestly. ✨


πŸ‘‘ NOTES πŸ‘‘

🚨 heads up bestie: these functions do NOT check whether an attribute of the same type is already hanging out in there.

so yeah β€” you can absolutely end up with multiple attributes of the same type assigned to one safeBag. no dedupe, no warning, no "hey girl are you sure." it just adds. it's giving "no thoughts, head empty, only append." πŸ’€

also! both functions were added in OpenSSL 3.0. so if you're on something older, this is not your era. sorry babe. πŸ™ˆ


⭐ RETURN VALUES ⭐

  • 1 = slay, success, it worked. πŸŽ‰
  • 0 = nope, failure, it did not work. 😭

🌈 SEE ALSO 🌈


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


ok that's the whole page, no notes, you ate that. this was version 3.5.9, dated 2026-09-29, and yes it's still PKCS12_ADD1_ATTR_BY_NID(3ossl) β€” periodt. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from