PKCS12_SAFEBAG_GET1_CERT(3ossl)
π PKCS12_SAFEBAG_GET1_CERT(3ossl) π
okay so this is a whole family of getters from OpenSSL's pkcs12.h β like, the 3ossl manual section, bestie, we're in the big leagues now. Buckle up. π¦
β¨ NAME β¨
Bestie, this is a whole squad of functions, and every single one of them is here to pull objects out of a PKCS#12 safeBag. The lineup:
PKCS12_SAFEBAG_get0_attrPKCS12_SAFEBAG_get0_typePKCS12_SAFEBAG_get_nidPKCS12_SAFEBAG_get_bag_nidPKCS12_SAFEBAG_get0_bag_objPKCS12_SAFEBAG_get0_bag_typePKCS12_SAFEBAG_get1_cert_exPKCS12_SAFEBAG_get1_certPKCS12_SAFEBAG_get1_crl_exPKCS12_SAFEBAG_get1_crlPKCS12_SAFEBAG_get0_safesPKCS12_SAFEBAG_get0_p8infPKCS12_SAFEBAG_get0_pkcs8
and their collective whole vibe is: get objects from a PKCS#12 safeBag. periodt. π
πΈ SYNOPSIS πΈ
#include <openssl/pkcs12.h>
const ASN1_TYPE *PKCS12_SAFEBAG_get0_attr(const PKCS12_SAFEBAG *bag,
int attr_nid);
const ASN1_OBJECT *PKCS12_SAFEBAG_get0_type(const PKCS12_SAFEBAG *bag);
int PKCS12_SAFEBAG_get_nid(const PKCS12_SAFEBAG *bag);
int PKCS12_SAFEBAG_get_bag_nid(const PKCS12_SAFEBAG *bag);
const ASN1_TYPE *PKCS12_SAFEBAG_get0_bag_obj(const PKCS12_SAFEBAG *bag);
const ASN1_OBJECT *PKCS12_SAFEBAG_get0_bag_type(const PKCS12_SAFEBAG *bag);
X509_CRL *PKCS12_SAFEBAG_get1_cert_ex(const PKCS12_SAFEBAG *bag,
OSSL_LIB_CTX *libctx, const char *propq);
X509 *PKCS12_SAFEBAG_get1_cert(const PKCS12_SAFEBAG *bag);
X509_CRL *PKCS12_SAFEBAG_get1_crl_ex(const PKCS12_SAFEBAG *bag,
OSSL_LIB_CTX *libctx, const char *propq);
X509_CRL *PKCS12_SAFEBAG_get1_crl(const PKCS12_SAFEBAG *bag);
const STACK_OF(PKCS12_SAFEBAG) *PKCS12_SAFEBAG_get0_safes(const PKCS12_SAFEBAG *bag);
const PKCS8_PRIV_KEY_INFO *PKCS12_SAFEBAG_get0_p8inf(const PKCS12_SAFEBAG *bag);
const X509_SIG *PKCS12_SAFEBAG_get0_pkcs8(const PKCS12_SAFEBAG *bag);
look at all those signatures, literally gorgeous π copy them exactly, no cap, they're case-sensitive and the consts are load-bearing.
π§ DESCRIPTION π§
okay so let's go through these one at a time, group-chat style, because there are a lot of them and every single one matters:
PKCS12_SAFEBAG_get0_attr()β grabs the attribute value that matchesattr_nid. that's it. that's the whole function. slay. πPKCS12_SAFEBAG_get0_type()β hands you the safeBag type, but as an OID.PKCS12_SAFEBAG_get_nid()β same idea, but the safeBag type comes back as an NID instead. and that NID could beNID_certBag,NID_crlBag,NID_keyBag,NID_secretBag,NID_safeContentsBagorNID_pkcs8ShroudedKeyBag. iconic little enum family, love them. π«ΆPKCS12_SAFEBAG_get_bag_nid()β this one gets the type of the object contained within thePKCS12_SAFEBAG. subtle difference, bestie: this corresponds to the bag type for most bags, but it can be arbitrary for secretBags. so don't go assuming. πPKCS12_SAFEBAG_get0_bag_type()β takes that same type and gives it to you as an OID.PKCS12_SAFEBAG_get0_bag_obj()β retrieves the object contained within the safeBag. the actual goods. π¦PKCS12_SAFEBAG_get1_cert_ex()andPKCS12_SAFEBAG_get1_crl_ex()β these return brand-newX509orX509_CRLobjects (yes, new β the "1" in the name is doing real work) from the item in the safeBag. thelibctxandpropqparams get used when fetching algorithms, and you can optionally set them toNULL.PKCS12_SAFEBAG_get1_cert()andPKCS12_SAFEBAG_get1_crl()β literally the same asPKCS12_SAFEBAG_get1_cert_ex()andPKCS12_SAFEBAG_get1_crl_ex(), except they set thelibctxand prop toNULL. which means: this will use the default library context. πPKCS12_SAFEBAG_get0_p8inf()andPKCS12_SAFEBAG_get0_pkcs8()β return the PKCS8 object from aPKCS8shroudedKeyBagor akeyBag.PKCS12_SAFEBAG_get0_safes()β retrieves the set of safeBags contained within asafeContentsBag. bags inside bags, it's giving inception π
π₯ RETURN VALUES π₯
PKCS12_SAFEBAG_get_nid()andPKCS12_SAFEBAG_get_bag_nid()return the NID of the safeBag or bag object β or-1if there is no corresponding NID. so like, check for the-1, bestie, don't just vibe-check it and move on. π- other functions return a valid object of the specified type, or
NULLif an error occurred.
ngl,-1for the int-returning ones andNULLfor everything else β memorize that split, it's the whole plot twist.
β SEE ALSO β
go read these next, they're the linked lore:
π¦ HISTORY π¦
PKCS12_SAFEBAG_get1_cert_ex()andPKCS12_SAFEBAG_get1_crl_ex()were added in OpenSSL 3.2. newcomers, but already main character energy. π
π COPYRIGHT π
Copyright 2019-2023 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>.
that's the whole page, bestie π«Ά β and for the record, this little masterpiece is from OpenSSL 3.5.0, dated 2026-09-25, filed under PKCS12_SAFEBAG_GET1_CERT(3ossl). go forth and get those safeBag objects πβ¨π
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms