SSL_SET_SESSION(3SSL)
π SSL_SET_SESSION π
okay bestie, welcome to the SSL_set_session(3SSL) page from the OpenSSL manual β yes, the whole OpenSSL manual, we're in the big leagues now π
β¨ NAME β¨
SSL_set_session β set a TLS/SSL session to be used during TLS/SSL connect π«Ά
πΈ SYNOPSIS πΈ
#include <openssl/ssl.h>
int SSL_set_session(SSL *ssl, SSL_SESSION *session);
π¦ DESCRIPTION π¦
So like. SSL_set_session() sets session to be used when the TLS/SSL connection is to be established. That's the whole job. Slay.
Quick vibe check tho: SSL_set_session() is only useful for TLS/SSL clients. Servers, this one is not for you, sorry babe π
The way that reference counting works here is so important, so listen up:
- When the session is set, the reference count of session is incremented by 1.
- If the session is not reused, the reference count is decremented again during
SSL_connect(). - Wanna know if the session actually got reused? Query it with
SSL_session_reused(3)π
And here's the part where things get a lil dramatic π β if there is already a session set inside ssl (because it was set with SSL_set_session() before, or because the same ssl was already used for a connection), then SSL_SESSION_free() will be called for that session. Yes, even when session is a NULL pointer. No escape.
β οΈ And if that old session is still open, it is considered bad and will be removed from the session cache (if used). A session counts as open ifSSL_shutdown(3)was not called for the connection β or, at the very least,SSL_set_shutdown(3)was used to set theSSL_SENT_SHUTDOWNstate. Keep your sessions closed, babes, it's giving hygiene π§Ό
π NOTES π
okay this is the "iykyk" section, fr fr.
SSL_SESSION objects keep internal link information about the session cache list when being inserted into one SSL_CTX object's session cache.
So because of that: one SSL_SESSION object, regardless of its reference count, must therefore only be used with one SSL_CTX object (and the SSL objects created from this SSL_CTX object). No sharing. No side-eyeing other contexts. Monogamy only πβ¨
π RETURN VALUES π
Here's what can come back at you:
0β the operation failed; check the error stack to find out the reason. π1β the operation succeeded. π ate, no crumbs
π SEE ALSO π
go read these next, bestie, they're all connected:
ssl(7)SSL_SESSION_free(3)SSL_get_session(3)SSL_session_reused(3)SSL_CTX_set_session_cache_mode(3)
π COPYRIGHT π
Copyright 2000-2022 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, periodt π
β¨ this one came from OpenSSL 4.0.3, dated 2026-09-29, and it lives under the name SSL_SET_SESSION(3SSL). go forth and set those sessions, bestie ππ¦π
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms