SSL_SESSION_GET0_PEER(3ossl)

πŸ’– SSL_SESSION_GET0_PEER πŸ’–

okay bestie, welcome to SSL_SESSION_GET0_PEER(3ossl) β€” the lil OpenSSL manual page that hands you the peer's certificate like it's a friendship bracelet and says "here, don't lose it, and also don't throw it away." πŸŽ€


🌸 NAME 🌸

SSL_SESSION_get0_peer β€” get details about peer's certificate for a session

✨ SYNOPSIS ✨

#include <openssl/ssl.h>

X509 *SSL_SESSION_get0_peer(SSL_SESSION *s);

πŸ¦‹ DESCRIPTION πŸ¦‹

so SSL_SESSION_get0_peer() returns the peer certificate associated with the session s, or NULL if no peer certificate is available. that's it. that's the whole vibe. one function, one job, and she ate πŸ’…

and listen β€” the caller should not free the returned value unless X509_up_ref(3) has also been called. no cap. that pointer is borrowed, not yours to yeet into free(). if you free it anyway you're gonna have a bad time and the memory allocator is gonna be like "girl what did you do" 😭

🫢 if you do want to keep it around past the session's lifetime, that's exactly what X509_up_ref(3) is for β€” bump the ref count first, then it's yours.

⭐ RETURN VALUES ⭐

SSL_SESSION_get0_peer() returns a pointer to the peer certificate, or NULL if no peer certificate is available. pointer = slay, NULL = no cert, we move on ✨

πŸ‘‘ SEE ALSO πŸ‘‘

Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that's the whole page, bestie!! πŸŽ€ this masterpiece of documentation is from OpenSSL 3.5.9, dated 2026-09-29, and it lives in the SSL_SESSION_GET0_PEER(3ossl) section β€” go forth, grab that peer cert, and do NOT free it πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from