SSL_SET_SESSION(3)
π SSL_SET_SESSION(3) π
okay bestie, so this one lives in the Library Functions Manual and it's part of the libssl / libcrypto fam β yes, the crypto girlies. Let's get into it β¨
πΈ SYNOPSIS πΈ
library βlibsslβ libcrypto #include <openssl/ssl.h>
int
SSL_set_session(SSL *ssl, SSL_SESSION *session);
π DESCRIPTION π
So SSL_set_session() sets session to be used when the TLS/SSL connection is about to be established. That's it, that's the vibe. π«Ά
Heads up though: SSL_set_session() is only useful for TLS/SSL clients. Server girlies, this one's not for you π
When the session is set, the reference count of session gets incremented by 1. Iconic. But if the session is not reused, that reference count gets decremented again during SSL_connect(). And if you're sitting there like "wait, was it even reused??" β you can query that with the SSL_session_reused(3) call. iykyk π
Now, if there's already a session set inside ssl β like, because it was set with SSL_set_session() before, or because the same ssl was already used for a connection β then SSL_SESSION_free(3) will be called for that session. Old session, your time is up π«‘
β οΈ BIG important warning, fr fr:SSL_SESSIONobjects keep internal link information about the session cache list when they get inserted into oneSSL_CTXobject's session cache. So oneSSL_SESSIONobject β regardless of its reference count β must therefore only be used with oneSSL_CTXobject (and theSSLobjects created from thisSSL_CTXobject). No sharing, no passing it around like a friendship bracelet. It's giving exclusive relationship π₯
β¨ RETURN VALUES β¨
These are the return values that can occur, bestie:
0β the operation failed π check the error stack to find out the reason.1β the operation succeeded π slay.
π¦ SEE ALSO π¦
ssl(3)SSL_CTX_set_session_cache_mode(3)SSL_get_session(3)SSL_SESSION_free(3)SSL_session_reused(3)
go read those, they're literally the supporting cast π
π HISTORY π
SSL_set_session() first appeared in SSLeay 0.5.2 and has been available since OpenBSD 2.4. a true elder, we stan an OG π§
aaaand that's the whole page! this lil gem came from the Debian edition, dated June 8, 2025 β mwah, bye bestie π π
π¦ 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, 2001, 2016 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms