SSL_SESSION_GET0_ID_CONTEXT(3SSL)

πŸ’– SSL_SESSION_get0_id_context β€” bestie edition πŸ’–

okay so this is a page from the OpenSSL manual, section 3SSL, and it's all about the SSL ID context that's vibing inside a session. two functions, one getter, one setter, extremely demure, extremely mindful. let's get into it πŸŽ€


✨ NAME ✨

SSL_SESSION_get0_id_context, SSL_SESSION_set1_id_context β€” grab and set the SSL ID context that's attached to a session 🫢


🌸 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 πŸ’…

first things first, if you want the full lore on session ID contexts, go read SSL_CTX_set_session_id_context(3). that's the deep dive. this page is the lil sibling page. πŸ‘‘

SSL_SESSION_get0_id_context() hands you back the ID context that's chillin' inside the SSL/TLS session s. it also writes the length of that ID context into *len β€” but only if len is not NULL, so if you're not curious about the length, just pass NULL and she'll keep it to herself, no cap.

⚠️ the value you get back is a pointer to an object maintained within s. do NOT release it. that pointer is not yours to free. put it down. step away. it's giving "borrowed, not given." 🚫

SSL_SESSION_set1_id_context() is the opposite vibe β€” it takes a copy of the ID context you provide in sid_ctx and associates that copy with the session s. so you can do whatever you want with your original buffer afterwards, she has her own. πŸ’–

the length of that ID context is sid_ctx_len, and here's the rule, no exceptions: it must not exceed SSL_MAX_SID_CTX_LENGTH bytes. that's the ceiling bestie, do not test it. 😭


⭐ RETURN VALUES ⭐

  • SSL_SESSION_set1_id_context() β€” returns 1 on success, or 0 on error. that's it, that's the whole report card. slay or flop. ✨

πŸ¦‹ SEE ALSO πŸ¦‹


🌈 HISTORY 🌈

the SSL_SESSION_get0_id_context() function was added in OpenSSL 1.1.0. she's been iconic since then, periodt. πŸ’œ


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>.


and that's the whole page bestie, every last crumb πŸ“ this was SSL_SESSION_GET0_ID_CONTEXT(3SSL), version 4.0.3, dated 2026-09-29 β€” go forth and set your ID contexts responsibly, mwah πŸ’‹βœ¨πŸŽ€

πŸ“¦ where this page comes from