SSL_SET_SESSION(3ossl)
π SSL_set_session β like, the session glow-up page (3ossl)
okay bestie, welcome to SSL_set_session from the OpenSSL fam π this one's a little cutie that tells your TLS/SSL connection which session to show up with. let's get into it β¨
πΈ NAME πΈ
SSL_set_session β set a TLS/SSL session to be used during TLS/SSL connect. yeah. that's the whole vibe check π«Ά
π SYNOPSIS π
#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 to be established. lowkey simple, highkey important π
and listen β SSL_set_session() is only useful for TLS/SSL clients. servers, this one's not for you, sorry bestie π
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(). so it goes back down, ngl. and if you're wondering "wait, was it reused tho??" β you can query that with the SSL_session_reused(3) call π¦
okay now the part where you gotta pay attention, bestie π if there's already a session set inside ssl β whether 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. and yeah, this is also the case when session is a NULL pointer. no cap.
and if that old session is still open? it's considered bad and will be removed from the session cache (if used). π a session is considered open if SSL_shutdown(3) was not called for the connection β or at least if SSL_set_shutdown(3) wasn't used to set the SSL_SENT_SHUTDOWN state. so like... wrap it up properly, okay??
π§ NOTES π§
here's the tea β SSL_SESSION objects keep internal link information about the session cache list when they're being inserted into one SSL_CTX object's session cache.
so 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). one ctx, one session, that's the rule, periodt π
π RETURN VALUES π
the following return values can occur:
0β the operation failed π check the error stack to find out the reason.1β the operation succeeded π₯ slay.
π¦ SEE ALSO π¦
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>.
that's the whole page bestie, go forth and set those sessions π this one's version 3.5.6, dated 2026-04-07, brought to you by the OpenSSL girlies β mwah, talk later ππ
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms