---
name: "libressl-PKCS12_SAFEBAG_new"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-PKCS12_SAFEBAG_new"
---

# libressl-PKCS12\_SAFEBAG\_new(3)

PKCS#12 container for one piece of information

## NAME

**PKCS12\_SAFEBAG\_new**, **PKCS12\_SAFEBAG\_free**, **PKCS12\_BAGS\_new**, **PKCS12\_BAGS\_free** – PKCS#12 container for one piece of information

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/pkcs12.h\>**

*PKCS12\_SAFEBAG* *\**\

**PKCS12\_SAFEBAG\_new**(*void*);

*void*\

**PKCS12\_SAFEBAG\_free**(*PKCS12\_SAFEBAG \*safebag*);

*PKCS12\_BAGS* *\**\

**PKCS12\_BAGS\_new**(*void*);

*void*\

**PKCS12\_BAGS\_free**(*PKCS12\_BAGS \*bag*);

## DESCRIPTION

**PKCS12\_SAFEBAG\_new**() allocates and initializes an empty *PKCS12\_SAFEBAG* object, representing an ASN.1 *SafeBag* structure defined in RFC 7292 section 4.2. It can hold a pointer to a *PKCS12\_BAGS* object together with a type identifier and optional attributes. **PKCS12\_SAFEBAG\_free**() frees *safebag*.

**PKCS12\_BAGS\_new**() allocates and initializes an empty *PKCS12\_BAGS* object, representing the bagValue field of an ASN.1 *SafeBag* structure. It is used in *PKCS12\_SAFEBAG* and can hold a DER-encoded X.509 certificate, a base64-encoded SDSI certificate, a DER-encoded X.509 CRL, or other user-defined information.

If an instance of *PKCS12\_SAFEBAG* contains *PKCS8\_PRIV\_KEY\_INFO*, *X509\_SIG*, or nested *PKCS12\_SAFEBAG* objects, the respective pointers are stored directly in the *PKCS12\_SAFEBAG* object rather than in the contained *PKCS12\_BAGS* object as required by RFC 7292.

## RETURN VALUES

**PKCS12\_SAFEBAG\_new**() and **PKCS12\_BAGS\_new**() return the new *PKCS12\_SAFEBAG* or *PKCS12\_BAGS* object, respectively, or NULL if an error occurs.

## SEE ALSO

PKCS12\_create(3), PKCS12\_new(3), PKCS8\_PRIV\_KEY\_INFO\_new(3), X509\_ATTRIBUTE\_new(3), X509\_CRL\_new(3), X509\_new(3), X509\_SIG\_new(3)

## STANDARDS

RFC 7292: PKCS #12: Personal Information Exchange Syntax, section 4.2: The SafeBag Type

## HISTORY

**PKCS12\_SAFEBAG\_new**(), **PKCS12\_SAFEBAG\_free**(), **PKCS12\_BAGS\_new**(), and **PKCS12\_BAGS\_free**() first appeared in OpenSSL 0.9.3 and have been available since OpenBSD 2.6.
