PKCS12_ADD1_ATTR_BY_NID(3ossl)
π 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 typenidwith a value of ASN1 typetype, constructed usinglenbytes frombytes.PKCS12_add1_attr_by_txt()β adds an attribute of typeattrnamewith a value of ASN1 typetype, constructed usinglenbytes frombytes.
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 π
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
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms