PKCS12_ADD1_ATTR_BY_NID(3ossl)

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

πŸ’… PKCS12_ADD1_ATTR_BY_NID β€” the 3ossl girlies' guide πŸ’…

okay so bestie, welcome to another OpenSSL manpage, this one lives in the 3ossl section and honestly? it's a short one, we love a low-effort queen. let's get into it πŸŽ€


✨ NAME ✨

PKCS12_add1_attr_by_NID, PKCS12_add1_attr_by_txt β€” the two functions that let you add an attribute to a PKCS#12 safeBag structure. yes, safeBag. that's really the name. not me giggling 😭


🌸 SYNOPSIS 🌸

she's a C girly, so you know we're including headers first, no cap:

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

copy that exactly bestie, character for character, I'm not playing 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, both of these functions add a PKCS#12 Attribute to the Attribute Set of the bag. that's it, that's the whole vibe. two little functions, one big job ✨

  • PKCS12_add1_attr_by_NID() β€” adds an attribute of type nid with a value of ASN1 type type, constructed using len bytes from bytes. she takes the number route, iykyk πŸ”’
  • PKCS12_add1_attr_by_txt() β€” adds an attribute of type attrname with a value of ASN1 type type, constructed using len bytes from bytes. same energy, but you're naming the attribute with a string instead πŸ”€

literally the same destination, two different roads to get there. main character energy from both of them fr fr πŸ’œ


🌈 NOTES 🌈

okay important, listen up bestie πŸ“’

  • these functions do not check whether an existing attribute of the same type is present. so like, no vibe check, no duplicate filter, nothing. it's giving "i own this bag" 🌚
  • there can be multiple attributes with the same type assigned to a safeBag. yes, multiple. the bag is a little hoarder and honestly we support her πŸ’…
also, both functions were added in OpenSSL 3.0, so if you're on something older, she does not exist and you will simply have to cope 😭

πŸ’– RETURN VALUES πŸ’–

short and sweet, just how we like it:

  • 1 means success, ate that, no crumbs πŸ”₯
  • 0 means failure, and we do NOT stan πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

go look at PKCS12_create(3) if you want the whole friend group, bestie, because these functions are just the supporting cast 🫢


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, read the license bestie, it's literally the rules of the group chat 🌸


and that's the whole page! ✨ this iconic little writeup is from version 3.5.0, dated 2026-09-25, and it's filed under PKCS12_ADD1_ATTR_BY_NID(3ossl) β€” mwah, go take care of your safeBags, xoxo πŸ’‹πŸ’–

πŸ“¦ where this page comes from