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

# libressl-SSL\_get\_peer\_cert\_chain(3)

get the X509 certificate chain sent by the peer

## NAME

**SSL\_get\_peer\_cert\_chain** – get the X509 certificate chain sent by the peer

## SYNOPSIS

SSL Library (libssl, -lssl) libcrypto

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

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

**SSL\_get\_peer\_cert\_chain**(*const SSL \*ssl*);

## DESCRIPTION

**SSL\_get\_peer\_cert\_chain**() returns a pointer to STACK\_OF(*X509*) certificates forming the certificate chain of the peer. If called on the client side, the stack also contains the peer's certificate; if called on the server side, the peer's certificate must be obtained separately using SSL\_get\_peer\_certificate(3). If the peer did not present a certificate, NULL is returned.

**SSL\_get\_peer\_cert\_chain**() returns the peer chain as sent by the peer: it only consists of certificates the peer has sent (in the order the peer has sent them) and it is not a verified chain.

If the session is resumed, peers do not send certificates, so a NULL pointer is returned. Applications can call **SSL\_session\_reused**() to determine whether a session is resumed.

The reference count of the STACK\_OF(*X509*) object is not incremented. If the corresponding session is freed, the pointer must not be used any longer.

## RETURN VALUES

The following return values can occur:

- NULL

  No certificate was presented by the peer or no connection was established or the certificate chain is no longer available when a session is reused.

- Pointer to a STACK\_OF(X509)

  The return value points to the certificate chain presented by the peer.

## SEE ALSO

[ssl(3)](/ssl/3.md), SSL\_get\_peer\_certificate(3)

## HISTORY

**SSL\_get\_peer\_cert\_chain**() first appeared in SSLeay 0.8.0 and has been available since OpenBSD 2.4.
