PKCS12_ADD_SAFE(3ossl)
π PKCS12_ADD_SAFE(3ossl) π
okay bestie, buckle up π
this is an OpenSSL manual page and honestly it's giving "glue code that holds your whole .p12 together" energy. It's all about PKCS12_add_safe, PKCS12_add_safe_ex, PKCS12_add_safes and PKCS12_add_safes_ex β the little functions that create and add objects to a PKCS#12 structure π
β¨ SYNOPSIS β¨
#include <openssl/pkcs12.h>
int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,
int safe_nid, int iter, const char *pass);
int PKCS12_add_safe_ex(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,
int safe_nid, int iter, const char *pass,
OSSL_LIB_CTX *ctx, const char *propq);
PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid);
PKCS12 *PKCS12_add_safes_ex(STACK_OF(PKCS7) *safes, int p7_nid,
OSSL_LIB_CTX *ctx, const char *propq);
πΈ DESCRIPTION πΈ
so PKCS12_add_safe() is the main character here π β it creates a new PKCS7 contentInfo containing the PKCS12_SAFEBAGs you handed it, and adds that to a set of PKCS7 contentInfos. The type of that contentInfo is fully up to safe_nid, and the vibe check goes like this:
- if
safe_nidis-1, you get a plain PKCS7 data contentInfo, no encryption, just vibes π¦ - if
safe_nidis a valid PBE algorithm NID, you get a PKCS7 encryptedData contentInfo. The algorithm takespassas the passphrase anditeras the iteration count. and like, ifiteris zero, a default iteration count of2048gets used instead β slay, defaults π₯ - if
safe_nidis0, you get a PKCS7 encryptedData contentInfo using a default encryption algorithm, which currently isNID_pbe_WithSHA1And3_Key_TripleDES_CBCπ
PKCS12_add_safe_ex() is literally identical to PKCS12_add_safe() bestie, except it also lets you pass a library context ctx and a property query propq so you can pick which algorithm implementations get used π§
then we have PKCS12_add_safes() β this one creates a PKCS12 structure containing the supplied set of PKCS7 contentInfos. The safes get enclosed first inside a PKCS7 contentInfo of type p7_nid. and ngl, currently the only supported type is NID_pkcs7_data π so don't get too creative.
PKCS12_add_safes_ex() is the exact same deal as PKCS12_add_safes(), but again with that library context ctx and property query propq for selecting algorithm implementations β¨
π«Ά NOTES π«Ά
heads up:PKCS12_add_safe()makes assumptions about the encoding of the pass phrase you give it π it's not out here reading minds. Go checkpassphrase-encoding(7)for the whole story, iykyk.
β RETURN VALUES β
PKCS12_add_safe()returns1to say success, or0for failure πPKCS12_add_safes()returns a valid PKCS12 structure, orNULLif an error happened π
π CONFORMING TO π
IETF RFC 7292 (https://tools.ietf.org/html/rfc7292) β yes, the actual spec, go read it if you're that kind of girl π
π¦ SEE ALSO π¦
π HISTORY π
PKCS12_add_safe_ex() and PKCS12_add_safes_ex() were added in OpenSSL 3.0 β the _ex girlies are relatively new, 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.
and that's the whole page bestie π«Ά mwah π β brought to you by 3.5.0, dated 2026-09-25, from the PKCS12_ADD_SAFE(3ossl) girlies themselves πΈβ¨
π¦ 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