PKCS12_SAFEBAG_CREATE_CERT(3ossl)
π PKCS12_SAFEBAG_CREATE_CERT π
okay so this is the 3ossl girlies' guide to makin' safeBag objects β yes that's literally what they're called, and yes it's from the <openssl/pkcs12.h> era of the OpenSSL manual pages. Buckle up bestie, we're building little gift bags for certs, CRLs, secrets and keys π
β¨ NAME β¨
So the whole squad here β PKCS12_SAFEBAG_create_cert, PKCS12_SAFEBAG_create_crl, PKCS12_SAFEBAG_create_secret, PKCS12_SAFEBAG_create0_p8inf, PKCS12_SAFEBAG_create0_pkcs8, PKCS12_SAFEBAG_create_pkcs8_encrypt and PKCS12_SAFEBAG_create_pkcs8_encrypt_ex β are all about creating PKCS#12 safeBag objects. That's the vibe. That's the whole job. πΌ
πΈ SYNOPSIS πΈ
#include <openssl/pkcs12.h>
PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_cert(X509 *x509);
PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_crl(X509_CRL *crl);
PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_secret(int type, int vtype,
const unsigned char* value,
int len);
PKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_p8inf(PKCS8_PRIV_KEY_INFO *p8);
PKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_pkcs8(X509_SIG *p8);
PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt(int pbe_nid,
const char *pass,
int passlen,
unsigned char *salt,
int saltlen, int iter,
PKCS8_PRIV_KEY_INFO *p8inf);
PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt_ex(int pbe_nid,
const char *pass,
int passlen,
unsigned char *salt,
int saltlen, int iter,
PKCS8_PRIV_KEY_INFO *p8inf,
OSSL_LIB_CTX *ctx,
const char *propq);
π¦ DESCRIPTION π¦
Alright, one by one, no skips, no cap:
PKCS12_SAFEBAG_create_cert()β makes a brand-newPKCS12_SAFEBAGof typeNID_certBag, and it's holding the certificate you handed it. cert bag, cert bag, cert bag πPKCS12_SAFEBAG_create_crl()β same energy but for revocation lists: a newPKCS12_SAFEBAGof typeNID_crlBagcontaining the supplied crl.PKCS12_SAFEBAG_create_secret()β creates a newPKCS12_SAFEBAGof the type that corresponds to a PKCS#12 secretBag. The secretBag contents get tagged as typetype, with an ASN1 value of typevtypeconstructed using the bytes invalueof lengthlen. iykyk π«ΆPKCS12_SAFEBAG_create0_p8inf()β makes a newPKCS12_SAFEBAGof typeNID_keyBagcontaining the supplied PKCS8 structure. key bag, iconic.PKCS12_SAFEBAG_create0_pkcs8()β makes a newPKCS12_SAFEBAGof typeNID_pkcs8ShroudedKeyBagcontaining the supplied PKCS8 structure. shrouded = mysterious = main character energy πPKCS12_SAFEBAG_create_pkcs8_encrypt()β creates a newPKCS12_SAFEBAGof typeNID_pkcs8ShroudedKeyBagby encrypting the supplied PKCS8p8inf. Deets:- if
pbe_nidis0, a default encryption algorithm is used passis the passphrase anditeris the iteration count- if
iteris zero then a default value of2048is used - if
saltisNULLthen a salt is generated randomly π§β¨
- if
PKCS12_SAFEBAG_create_pkcs8_encrypt_ex()β literally identical toPKCS12_SAFEBAG_create_pkcs8_encrypt()BUT it also lets you pass a library contextctxand a property querypropq, which are used to select algorithm implementations. fancy edition π
π NOTES π
β οΈ heads up bestie:PKCS12_SAFEBAG_create_pkcs8_encrypt()makes assumptions regarding the encoding of the given pass phrase. Seepassphrase-encoding(7)for more information. don't come for me, come for the man page π
Also, PKCS12_SAFEBAG_create_secret() was added in OpenSSL 3.0. so if you're on something ancient, that's a no from her π
π RETURN VALUES π
All of these functions return a valid PKCS12_SAFEBAG structure, or NULL if an error occurred. that's it. that's the tea. π
β CONFORMING TO β
IETF RFC 7292 (https://tools.ietf.org/html/rfc7292) β the standards girlies ate, no crumbs. π
πΈ SEE ALSO πΈ
go read those next, you're doing amazing sweetie π«Ά
π HISTORY π
PKCS12_SAFEBAG_create_pkcs8_encrypt_ex() was added in OpenSSL 3.0. the _ex suffix really said "i'm the upgraded version" β¨
π COPYRIGHT π
Copyright 2019-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.
k that's the whole page bestie, mwah π β this was PKCS12_SAFEBAG_CREATE_CERT(3ossl) from OpenSSL 3.5.0, dated 2026-09-25. periodt. π¦β¨
π¦ 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