PKCS12_SAFEBAG_CREATE_CERT(3SSL)
π NAME π
okay bestie, so these are the girlies that make PKCS#12 safeBag objects for you:
PKCS12_SAFEBAG_create_certPKCS12_SAFEBAG_create_crlPKCS12_SAFEBAG_create_secretPKCS12_SAFEBAG_create0_p8infPKCS12_SAFEBAG_create0_pkcs8PKCS12_SAFEBAG_create_pkcs8_encryptPKCS12_SAFEBAG_create_pkcs8_encrypt_ex
like. they literally build safeBags. that's the whole job. this is part of the OpenSSL 3SSL manual set, and honestly? iconic behavior π
β¨ 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);
slay. seven functions, one header, zero notes. let's get into it π
π¦ DESCRIPTION π¦
okay so here's the vibe check on every single one, no skips, no cap:
PKCS12_SAFEBAG_create_cert()β makes you a brand newPKCS12_SAFEBAGof typeNID_certBag, and it's holding the certificate you handed it. your cert? wrapped. periodt.PKCS12_SAFEBAG_create_crl()β same energy, different bag: a newPKCS12_SAFEBAGof typeNID_crlBag, carrying thecrlyou gave it. revocation lists deserve cute packaging too, fr fr.PKCS12_SAFEBAG_create_secret()β builds a newPKCS12_SAFEBAGof the type that corresponds to a PKCS#12 secretBag. the secretBag contents are tagged astype, with an ASN1 value of typevtypeconstructed out of the bytes invalue, which islenbytes long. little secret, big energy πPKCS12_SAFEBAG_create0_p8inf()β newPKCS12_SAFEBAG, typeNID_keyBag, containing thePKCS8structure you passed in. straight in, no encryption, we're feeling brave.PKCS12_SAFEBAG_create0_pkcs8()β newPKCS12_SAFEBAG, typeNID_pkcs8ShroudedKeyBag, containing the suppliedPKCS8structure.PKCS12_SAFEBAG_create_pkcs8_encrypt()β creates a newPKCS12_SAFEBAGof typeNID_pkcs8ShroudedKeyBagby encrypting the supplied PKCS8p8inf. the deets:- if
pbe_nidis0, a default encryption algorithm is used. default queen behavior π passis the passphrase anditeris the iteration count.- if
iteris zero, a default value of2048is used. - if
saltisNULL, then a salt is generated randomly. let the chaos pick β¨
- if
PKCS12_SAFEBAG_create_pkcs8_encrypt_ex()β literally identical toPKCS12_SAFEBAG_create_pkcs8_encrypt(), except it also lets you pass a library contextctxand a property querypropq, which get used to select algorithm implementations. same function, more control, main character energy π
πΈ NOTES πΈ
okay important one, bestie, don't scroll past this:PKCS12_SAFEBAG_create_pkcs8_encrypt()makes assumptions regarding the encoding of the given pass phrase. so go readpassphrase-encoding(7)for the full tea before you come for me.
also: PKCS12_SAFEBAG_create_secret() was added in OpenSSL 3.0. so if you're on something older, it's giving "not invited to the party" π
β RETURN VALUES β
all of these functions return a valid PKCS12_SAFEBAG structureβ¦ or NULL if an error occurred. that's it, that's the whole return story. NULL is the "we don't talk about it" of return values π
π CONFORMING TO π
IETF RFC 7292 (<https://tools.ietf.org/html/rfc7292>) β yes we're standards-compliant and yes we're cute about it.
π«Ά SEE ALSO π«Ά
go read those when you're done here, they're the extended universe iykyk
π§ HISTORY π§
PKCS12_SAFEBAG_create_pkcs8_encrypt_ex() was added in OpenSSL 3.0. glow-up era, truly.
π 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>.
and that's the whole page, bestie π this was OpenSSL version 4.0.3, dated 2026-09-29, from the PKCS12_SAFEBAG_CREATE_CERT(3SSL) manual β go forth and bag those safes, mwah πβ¨
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms