SSL_GET_PEER_CERT_CHAIN(3)
π SSL_GET_PEER_CERT_CHAIN(3) π
okay so bestie, this one's from the Library Functions Manual and it's literally all about peeking at the certificate chain your peer sent you. no cap, it's giving "i just want to see what you brought to the party" energy. let's get into it π
β¨ NAME β¨
SSL_get_peer_cert_chain β get the X509 certificate chain sent by the peer π¦
πΈ SYNOPSIS πΈ
library βlibsslβ libcrypto
#include <openssl/ssl.h>
STACK_OF(X509) *
SSL_get_peer_cert_chain(const SSL *ssl);
like, that's the whole vibe right there π
π DESCRIPTION π
SSL_get_peer_cert_chain() hands you back a pointer to a STACK_OF(X509) of certificates β that's the certificate chain of the peer, periodt. π₯
okay but here's where it gets spicy, so pay attention bestie:
- if you call it on the client side, the stack also contains the peer's certificate π
- if you call it on the server side, you gotta get the peer's certificate separately using
SSL_get_peer_certificate(3)π - and if the peer didn't present a certificate at all? you get
NULL. that's it. that's the whole thing. π
ngl, the important detail here is that 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. like, it's literally just what they handed over, not a glow-up-approved version β¨
and listen β 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. iykyk π§
π¨ huge heads up bestie: 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. like, do NOT keep using it after the session dips, fr fr π
β 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. slay π
π SEE ALSO π
ssl(3), 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. iconic behavior honestly, it's been serving since forever π
okay that's the whole page bestie, go forth and check those chains πβ¨πΈ
Deiban, June 8, 2025 β mwah, love u, bye! π π¦
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2000, 2005, 2014, 2016 The OpenSSL Project
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms