---
name: "libressl-CMS_add0_cert"
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-CMS_add0_cert"
---

# libressl-CMS\_add0\_cert(3)

CMS certificate and CRL utility functions

## NAME

**CMS\_add0\_cert**, **CMS\_add1\_cert**, **CMS\_get1\_certs**, **CMS\_add0\_crl**, **CMS\_add1\_crl**, **CMS\_get1\_crls** – CMS certificate and CRL utility functions

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*int*\

**CMS\_add0\_cert**(*CMS\_ContentInfo \*cms*, *X509 \*certificate*);

*int*\

**CMS\_add1\_cert**(*CMS\_ContentInfo \*cms*, *X509 \*certificate*);

*STACK\_OF(X509)* *\**\

**CMS\_get1\_certs**(*CMS\_ContentInfo \*cms*);

*int*\

**CMS\_add0\_crl**(*CMS\_ContentInfo \*cms*, *X509\_CRL \*crl*);

*int*\

**CMS\_add1\_crl**(*CMS\_ContentInfo \*cms*, *X509\_CRL \*crl*);

*STACK\_OF(X509\_CRL)* *\**\

**CMS\_get1\_crls**(*CMS\_ContentInfo \*cms*);

## DESCRIPTION

**CMS\_add0\_cert**() adds the *certificate* to the *certificates* field of *cms* if it is of the type *SignedData* or to the *originatorInfo.certs* field if it is of the type *EnvelopedData*. **CMS\_add1\_cert**() does the same and also increments the reference count of the *certificate* with X509\_up\_ref(3) in case of success.

**CMS\_get1\_certs**() returns all certificates in *cms*.

**CMS\_add0\_crl**() adds the *crl* to the *crls* field of *cms* if it is of the type *SignedData* or to the *originatorInfo.crls* field if it is of the type *EnvelopedData*. **CMS\_add1\_crl**() does the same and also increments the reference count of the *crl* with X509\_CRL\_up\_ref(3) in case of success.

**CMS\_get1\_crls**() returns any CRLs in *cms*.

An error occurs if *cms* is of any type other than *SignedData* or *EnvelopedData*.

The same *certificate* or *crl* must not be added to the same *cms* structure more than once.

## RETURN VALUES

**CMS\_add0\_cert**(), **CMS\_add1\_cert**(), **CMS\_add0\_crl**(), and **CMS\_add1\_crl**() return 1 for success or 0 for failure.

**CMS\_get1\_certs**() and **CMS\_get1\_crls**() return the STACK of certificates or CRLs or NULL if there are none or an error occurs. Possible errors are that the *cms* type is invalid or memory allocation failure. Not all errors result in an error on the error stack. The returned stack must be freed using the appropriate macro wrapper of sk\_pop\_free(3), namely sk\_X509\_pop\_free() or sk\_X509\_CRL\_pop\_free().

## SEE ALSO

CMS\_ContentInfo\_new(3), CMS\_encrypt(3), CMS\_final(3), CMS\_sign(3), ERR\_get\_error(3)

## STANDARDS

RFC 5652: Cryptographic Message Syntax

- section 5.1: SignedData Type

- section 6.1: EnvelopedData Type

## HISTORY

**CMS\_add0\_cert**(), **CMS\_add1\_cert**(), **CMS\_get1\_certs**(), **CMS\_add0\_crl**(), and **CMS\_get1\_crls**() first appeared in OpenSSL 0.9.8h and **CMS\_add1\_crl**() in OpenSSL 1.0.0. These functions have been available since OpenBSD 6.7.
