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 isnid, with a value of ASN1 typetype, and that value gets constructed usinglenbytes pulled frombytes.PKCS12_add1_attr_by_txt()β same vibe, but the attribute type isattrnameinstead of anid. value is still ASN1 typetype, still built fromlenbytes ofbytes.
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 π
PKCS12_create(3)β go read that one too, 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>.
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
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms