PKCS12_ADD_CERT(3ossl)
β¨ NAME β¨
Okay so PKCS12_ADD_CERT(3ossl) is the manual for a whole little squad: PKCS12_add_cert, PKCS12_add_key, PKCS12_add_key_ex, and PKCS12_add_secret. Their collective vibe? Add an object to a set of PKCS#12 safeBags. That's the job, bestie π
.
πΈ 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 π¦
These functions create a new PKCS12_SAFEBAG and add it to the set of safeBags in pbags. It's giving "make a bag, put it with the other bags" β¨.
PKCS12_add_cert()β creates a PKCS#12certBagcontaining the supplied certificate and adds this to the set of PKCS#12safeBags. Cert bag, but make it iconic π.PKCS12_add_key()β creates a PKCS#12keyBag(unencrypted) or apkcs8shroudedKeyBag(encrypted) containing the suppliedEVP_PKEYand adds this to the set of PKCS#12safeBags. Ifkey_nidis not-1then the key is encrypted with the supplied algorithm, usingpassas the passphrase anditeras the iteration count. Ifiteris zero then a default value for iteration count of2048is used. Not the default being 2048 and me feeling powerful π.PKCS12_add_key_ex()β identical toPKCS12_add_key()but allows for a library contextctxand property querypropqto be used to select algorithm implementations. Same function, extra little settings, highkey slay π .PKCS12_add_secret()β creates a PKCS#12secretBagwith an OID corresponding to the suppliednid_typecontaining the suppliedvalueas anASN1 octet string. This is then added to the set of PKCS#12safeBags. Secret bag? More like main character bag π₯.
π NOTES π
- If a certificate contains an alias or a
keyidthen this will be used for the correspondingfriendlyNameorlocalKeyIDin the PKCS12 structure. Your cert is basically picking its own nickname, no cap π . PKCS12_add_key()makes assumptions regarding the encoding of the given pass phrase. Seepassphrase-encoding(7)for more information. Go read that one, bestie π«Ά.
π₯Ί RETURN VALUES π₯Ί
A valid PKCS12_SAFEBAG structure or NULL if an error occurred. That's the whole mood: valid struct or sad little NULL π.
π CONFORMING TO π
IETF RFC 7292 (<https://tools.ietf.org/html/rfc7292>). Standards bestie behavior β.
π SEE ALSO π
PKCS12_create(3) β go peek at that one too, iykyk π¦.
β HISTORY β
PKCS12_add_secret() and PKCS12_add_key_ex() were added in OpenSSL 3.0. They're the newer additions to the squad, periodt π.
π 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.
xoxo, your Unix bestie π β OpenSSL 3.5.0, dated 2026-09-25, manual PKCS12_ADD_CERT(3ossl) π«Ά
π¦ 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