SSL_SESSION_GET0_ID_CONTEXT(3ossl)

✨ SSL_SESSION_GET0_ID_CONTEXT(3ossl) ✨

okay bestie so this is the tea on two little OpenSSL functions β€” SSL_SESSION_get0_id_context and SSL_SESSION_set1_id_context β€” and they're literally the getter and setter for the SSL ID context that's chillin' inside a session. It's giving very much "one reads, one writes, we stay balanced πŸ’…". Part of the OpenSSL fam, iykyk.


πŸ¦‹ NAME πŸ¦‹

SSL_SESSION_get0_id_context, SSL_SESSION_set1_id_context β€” get and set the SSL ID context associated with a session, no cap 🫢


🌸 SYNOPSIS 🌸

#include <openssl/ssl.h>

const unsigned char *SSL_SESSION_get0_id_context(const SSL_SESSION *s,
                                                 unsigned int *len);
int SSL_SESSION_set1_id_context(SSL_SESSION *s, const unsigned char *sid_ctx,
                               unsigned int sid_ctx_len);

πŸ’– DESCRIPTION πŸ’–

So like, the whole lore of session ID contexts? Go read SSL_CTX_set_session_id_context(3), she explains it properly. This page is just the session-level version of that vibe.

SSL_SESSION_get0_id_context() β€” she's the reader. She hands you back the ID context that's associated with the SSL/TLS session s. And if len is not NULL, the length of that ID context gets written into *len. Simple. Iconic. ✨

Heads up bestie, the value she gives you is a pointer to an object that lives inside s, so do NOT release it. It's not yours to free. Hands off. πŸ™ˆ

SSL_SESSION_set1_id_context() β€” she's the writer. She takes a copy of the ID context you pass in sid_ctx and attaches it to the session s. The length of that ID context comes from sid_ctx_len, and listen β€” it must not exceed SSL_MAX_SID_CTX_LENGTH bytes. That's the limit, don't push it. 🚫


πŸ‘‘ RETURN VALUES πŸ‘‘

SSL_SESSION_set1_id_context() returns 1 when it slays (success) or 0 on error. That's it, that's the whole report card.


🌈 SEE ALSO 🌈

go read those too, they're part of the cinematic universe πŸŽ€


🧚 HISTORY 🧚

SSL_SESSION_get0_id_context() was added in OpenSSL 1.1.0 β€” so she's been around a minute, a true veteran of the game. ⭐


Copyright 2015-2020 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>.


k bye bestie, this page was brought to you by version 3.5.9, dated 2026-09-29, and the letter πŸ’… β€” go forth and handle your session ID contexts responsibly, mwah 🫢✨

πŸ“¦ where this page comes from