PKCS12_ADD1_ATTR_BY_NID(3SSL)

πŸ’– NAME πŸ’–

ok so bestie, meet the duo: PKCS12_add1_attr_by_NID and PKCS12_add1_attr_by_txt β€” they add an attribute to a PKCS#12 safeBag structure. that's it, that's the whole job, and they do it flawlessly, no cap. ✨

(this is the 3SSL man page, for the OpenSSL crowd β€” iykyk 🌸)


πŸŽ€ 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);

literally just two little functions, both returning int, both so well-behaved 🫢


🌈 DESCRIPTION 🌈

okay so here's the tea: these functions add a PKCS#12 Attribute to the Attribute Set of the bag. the bag in question being your PKCS12_SAFEBAG. she's getting accessories, and honestly? the bag ate. πŸ‘‘

PKCS12_add1_attr_by_NID() adds an attribute of type nid with a value of ASN1 type type constructed using len bytes from bytes. so: you hand her a NID, a type, a chunk of bytes, and how many of those bytes matter β€” and she builds the value for you. iconic behaviour πŸ’…

PKCS12_add1_attr_by_txt() does the exact same glow-up, except you give her an attribute name as text: it adds an attribute of type attrname with a value of ASN1 type type constructed using len bytes from bytes. same energy, different way in. slay ✨


πŸ’€ NOTES πŸ’€

major heads up bestie: 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. she's not gatekeeping, she's not deduping β€” she just adds, periodt. so if you call her twice with the same type, you get two. that's the vibe. 😭

also β€” both functions were added in OpenSSL 3.0. so if you're on something older, they simply do not exist for you, sorry babe πŸ’œ


⭐ RETURN VALUES ⭐

super simple, no plot twist:

  • a return value of 1 means success β€” she ate πŸ”₯
  • a return value of 0 means failure β€” it's giving nothing πŸ˜”

πŸ¦‹ 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>.


okay that's the whole page, you're officially educated, go forth and add attributes responsibly πŸ’–βœ¨

this was OpenSSL 4.0.3, dated 2026-09-29, straight from the PKCS12_ADD1_ATTR_BY_NID(3SSL) page β€” stay hydrated, read your man pages, and remember: the bag always deserves a little treat πŸŽ€πŸ«ΆπŸŒˆ

πŸ“¦ where this page comes from