SSL_SESSION_SET1_ID(3SSL)
π NAME π
SSL_SESSION_get_id, SSL_SESSION_set1_id β bestie, we're getting and setting the SSL session ID β¨
Okay so real talk, this is the OpenSSL page SSL_SESSION_SET1_ID(3SSL) and it's literally just two little functions that read and write the session id on an SSL_SESSION. Tiny API, big main-character energy. Let's go π
πΈ SYNOPSIS πΈ
#include <openssl/ssl.h>
const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s,
unsigned int *len);
int SSL_SESSION_set1_id(SSL_SESSION *s, const unsigned char *sid,
unsigned int sid_len);
β¨ DESCRIPTION β¨
SSL_SESSION_get_id() hands you a pointer to the internal session id value for the session s. Cute, right? And where does the length go? Into *len, in bytes. Periodt.
Heads up bestie: the length may be 0. Zero is a valid length, it's not a mistake, don't panic π
Also, super important: the caller should not free the returned pointer directly. It's the session's own internal pointer, not a present it's gifting you. Do NOT free() it. That's the vibe check, and it will not pass π
SSL_SESSION_set1_id() sets the session ID for the ssl SSL/TLS session to sid, of length sid_len. That's it. That's the whole function. Iconic honestly π
π RETURN VALUES π
SSL_SESSION_get_id()returns a pointer to the session id value π«ΆSSL_SESSION_set1_id()returns 1 for success and 0 for failure β for example if the supplied session ID length exceedsSSL_MAX_SSL_SESSION_ID_LENGTH. So yeah, overlong id = no β, back to 0 you go. Not me getting rejected by a length check π
π¦ SEE ALSO π¦
β HISTORY β
The SSL_SESSION_set1_id() function was added in OpenSSL 1.1.0. So it's been serving looks since 1.1.0, no cap π
π COPYRIGHT π
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 β go forth and slay your session IDs π
β¨ This was 4.0.3, dated 2026-09-29, signing off from the SSL_SESSION_SET1_ID(3SSL) group chat πππ¦
π¦ 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