PKCS12_ADD_CERT(3ossl)
π PKCS12_ADD_CERT π
okay bestie, welcome to the 3ossl manual page for PKCS12_add_cert β plus its whole little friend group: PKCS12_add_key, PKCS12_add_key_ex, and PKCS12_add_secret. this is the "add an object to a set of PKCS#12 safeBags" page and it is lowkey iconic π
β¨ NAME β¨
PKCS12_add_cert, PKCS12_add_key, PKCS12_add_key_ex, PKCS12_add_secret β Add an object to a set of PKCS#12 safeBags π«Ά
πΈ SYNOPSIS πΈ
#include <openssl/pkcs12.h>
PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert);
PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags,
EVP_PKEY *key, int key_usage, int iter,
int key_nid, const char *pass);
PKCS12_SAFEBAG *PKCS12_add_key_ex(STACK_OF(PKCS12_SAFEBAG) **pbags,
EVP_PKEY *key, int key_usage, int iter,
int key_nid, const char *pass,
OSSL_LIB_CTX *ctx, const char *propq);
PKCS12_SAFEBAG *PKCS12_add_secret(STACK_OF(PKCS12_SAFEBAG) **pbags,
int nid_type, const unsigned char *value, int len);
π¦ DESCRIPTION π¦
so like, all four of these functions do the same main character move: they create a brand-new PKCS12_SAFEBAG and drop it into the set of safeBags living in pbags. no cap. β¨
PKCS12_add_cert()β makes a PKCS#12 certBag holding the certificate you hand it, then adds that bag to the set of PKCS#12 safeBags. it's giving "here's my cert, put it in the bag" πPKCS12_add_key()β makes a PKCS#12 keyBag (that's the unencrypted one) or a pkcs8shroudedKeyBag (the encrypted one) holding theEVP_PKEYyou gave it, and adds it to the set of PKCS#12 safeBags. now listen: ifkey_nidis not-1, the key gets encrypted with the supplied algorithm, usingpassas the passphrase anditeras the iteration count. and ifiteris zero? a default iteration count value of2048is used. periodt. π₯PKCS12_add_key_ex()β literally identical toPKCS12_add_key(), except it also lets a library contextctxand a property querypropqbe used to select algorithm implementations. that's it, that's the whole glow-up. πPKCS12_add_secret()β makes a PKCS#12 secretBag with an OID corresponding to the suppliednid_type, holding the suppliedvalueas an ASN1 octet string. then it gets added to the set of PKCS#12 safeBags. sneaky little secret, we love her π€«π
β NOTES β
if a certificate contains an alias or a keyid, then that will be used for the corresponding friendlyName or localKeyID in the PKCS12 structure. so the cert basically already picked out its own nickname, iykyk. π
heads up bestie:PKCS12_add_key()makes assumptions regarding the encoding of the given pass phrase. seepassphrase-encoding(7)for more information. don't skip that one, fr fr. π
π RETURN VALUES π
a valid PKCS12_SAFEBAG structure, or NULL if an error occurred. that's the whole vibe check. π
π CONFORMING TO π
IETF RFC 7292 (<https://tools.ietf.org/html/rfc7292>) β we stay standards-compliant in this house. π
π§ SEE ALSO π§
π HISTORY π
PKCS12_add_secret() and PKCS12_add_key_ex() were added in OpenSSL 3.0. glow-up acquired. β¨
π COPYRIGHT π
Copyright 2020-2021 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>.
and that's the whole page, bestie!! π«Ά this one came from OpenSSL 3.5.9, dated 2026-09-29, and it goes by PKCS12_ADD_CERT(3ossl). mwah, go forth and bag those safeBags π
πΈ
π¦ 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