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

# libressl-X509\_OBJECT\_get0\_X509(3)

certificate, CRL, private key, and string wrapper for certificate stores

## NAME

**X509\_OBJECT\_get\_type**, **X509\_OBJECT\_new**, **X509\_OBJECT\_free**, **X509\_OBJECT\_get0\_X509**, **X509\_OBJECT\_get0\_X509\_CRL**, **X509\_OBJECT\_idx\_by\_subject**, **X509\_OBJECT\_retrieve\_by\_subject**, **X509\_OBJECT\_retrieve\_match** – certificate, CRL, private key, and string wrapper for certificate stores

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/x509\_vfy.h\>**

*X509\_LOOKUP\_TYPE*\

**X509\_OBJECT\_get\_type**(*const X509\_OBJECT \*obj*);

*X509\_OBJECT* *\**\

**X509\_OBJECT\_new**(*void*);

*void*\

**X509\_OBJECT\_free**(*X509\_OBJECT \*obj*);

*X509* *\**\

**X509\_OBJECT\_get0\_X509**(*const X509\_OBJECT \*obj*);

*X509\_CRL* *\**\

**X509\_OBJECT\_get0\_X509\_CRL**(*X509\_OBJECT \*obj*);

*int*\

**X509\_OBJECT\_idx\_by\_subject**(*STACK\_OF(X509\_OBJECT) \*stack*, *X509\_LOOKUP\_TYPE type*, *X509\_NAME \*name*);

*X509\_OBJECT* *\**\

**X509\_OBJECT\_retrieve\_by\_subject**(*STACK\_OF(X509\_OBJECT) \*stack*, *X509\_LOOKUP\_TYPE type*, *X509\_NAME \*name*);

*X509\_OBJECT* *\**\

**X509\_OBJECT\_retrieve\_match**(*STACK\_OF(X509\_OBJECT) \*stack*, *X509\_OBJECT \*obj*);

## DESCRIPTION

The *X509\_OBJECT* structure is a shallow wrapper around one *X509* certificate object or one *X509\_CRL* certificate revocation list object. The type of object stored at any given time can be inspected with **X509\_OBJECT\_get\_type**().

Each *X509\_STORE* object uses one stack of *X509\_OBJECT* structures as its main storage area.

**X509\_OBJECT\_new**() allocates a new *X509\_OBJECT* structure. It sets the object type to X509\_LU\_NONE and the pointer to the certificate or CRL to NULL.

If *obj* contains an *X509* certificate, **X509\_OBJECT\_free**() calls X509\_free(3) on that inner object. If *obj* contains an *X509\_CRL* certificate revocation list, it calls X509\_CRL\_free(3) on that inner list. **X509\_OBJECT\_free**() then frees the storage used for the *obj* itself.

If *type* is X509\_LU\_X509, **X509\_OBJECT\_idx\_by\_subject**() and **X509\_OBJECT\_retrieve\_by\_subject**() search the given *stack* for a certificate with the subject *name*. If *type* is X509\_LU\_CRL, they search for a certificate revocation list with the issuer *name* instead.

If *obj* contains a certificate, **X509\_OBJECT\_retrieve\_match**() searches the given *stack* for a certificate with a matching subject name; if it contains a certificate revocation list, it searches for a certificate revocation list with a matching issuer name instead; otherwise, it searches for an *X509\_OBJECT* with a matching type.

## RETURN VALUES

**X509\_OBJECT\_get\_type**() returns X509\_LU\_X509 if *obj* contains a certificate, X509\_LU\_CRL if it contains a certificate revocation list, or X509\_LU\_NONE if it contains neither.

**X509\_OBJECT\_new**() returns the new object or NULL if memory allocation fails.

**X509\_OBJECT\_get0\_X509**() returns an internal pointer to the certificate contained in *obj* or NULL if *obj* is NULL or contains no certificate.

**X509\_OBJECT\_get0\_X509\_CRL**() returns an internal pointer to the certificate revocation list contained in *obj* or NULL if *obj* is NULL or contains no certificate revocation list.

**X509\_OBJECT\_idx\_by\_subject**() returns the zero-based index of the first matching certificate or revocation list in the *stack* or -1 if *type* is neither X509\_LU\_X509 nor X509\_LU\_CRL or if no match is found.

**X509\_OBJECT\_retrieve\_by\_subject**() returns the first matching certificate or revocation list in the *stack* or NULL if *type* is neither X509\_LU\_X509 nor X509\_LU\_CRL or if no match is found.

**X509\_OBJECT\_retrieve\_match**() returns the first matching *X509\_OBJECT* or NULL if *stack* or *obj* is NULL or no match is found.

## SEE ALSO

STACK\_OF(3), X509\_CRL\_new(3), X509\_LOOKUP\_new(3), X509\_NAME\_new(3), X509\_new(3), X509\_STORE\_get0\_objects(3), X509\_STORE\_get\_by\_subject(3), X509\_STORE\_load\_locations(3), X509\_STORE\_new(3)

## HISTORY

**X509\_OBJECT\_idx\_by\_subject**(), **X509\_OBJECT\_retrieve\_by\_subject**(), and **X509\_OBJECT\_retrieve\_match**() first appeared in OpenSSL 0.9.6 and have been available since OpenBSD 2.9.

**X509\_OBJECT\_get\_type**(), **X509\_OBJECT\_get0\_X509**(), and **X509\_OBJECT\_get0\_X509\_CRL**() first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 6.3.

**X509\_OBJECT\_new**() and **X509\_OBJECT\_free**() first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 7.1.
