LIBRESSL-SSL_SESSION_GET_EX_NEW_INDEX(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸ¦‹ SSL_SESSION_GET_EX_NEW_INDEX(3) β€” Library Functions Manual πŸ¦‹

okay bestie, pull up a chair πŸ’… this one lives in the Library Functions Manual and it's all about the little secret pocket of app-specific data you can stash inside an SSL_SESSION β€” the internal application specific data functions, as the suits would say ✨


🌸 NAME 🌸

SSL_SESSION_get_ex_new_index, SSL_SESSION_set_ex_data, SSL_SESSION_get_ex_data β€” the internal application specific data functions, aka the ✨custom-extra-data✨ squad 🫢

heads up bestie: the page header at the top is actually truncated to SSL_SESSION_GET_EX_NEW_I(3) (ikr, somebody ran out of room 😭). The real full name is SSL_SESSION_GET_EX_NEW_INDEX(3). Same icon, different wig πŸ’€

✨ SYNOPSIS ✨

first, the vibes check β€” you're linking against library "libssl" and libcrypto, and you'd better have this up top:

#include <openssl/ssl.h>

then the functions themselves, no cap:

int
SSL_SESSION_get_ex_new_index(long argl, void *argp,
    CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
    CRYPTO_EX_free *free_func);

int
SSL_SESSION_set_ex_data(SSL_SESSION *session, int idx, void *arg);

void *
SSL_SESSION_get_ex_data(const SSL_SESSION *session, int idx);

 typedef int new_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
                int idx, long argl, void *argp);
 typedef void free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
                int idx, long argl, void *argp);
 typedef int dup_func(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
                int idx, long argl, void *argp);

πŸ’– DESCRIPTION πŸ’–

So here's the tea β˜• β€” several OpenSSL structures can have application specific data attached to them. Like, you can glue your own little data blob onto a struct and it just… lives there πŸŽ€

These three functions are used internally by OpenSSL to manipulate that application-specific data attached to a specific structure. Internal bestie behavior, iykyk πŸ’…

  • SSL_SESSION_get_ex_new_index() β€” registers a brand new index for application-specific data. Think of it as claiming your own lil locker number πŸ”‘βœ¨
  • SSL_SESSION_set_ex_data() β€” stores application data at arg for idx into the session object. Your stuff, your slot, slotted in 🫢
  • SSL_SESSION_get_ex_data() β€” retrieves the information for idx from session. The reunion moment πŸ˜­πŸ’–

and if you want the full deep-dive lore: a detailed description for the *_get_ex_new_index() functionality can be found in RSA_get_ex_new_index(3). The *_get_ex_data() and *_set_ex_data() functionality is described in CRYPTO_set_ex_data(3). go read your lore, bestie πŸ“š


⚠️ WARNINGS ⚠️

🚨 okay this part matters, do NOT skip it 🚨

The application data is only maintained for sessions held in memory. That's it. That's the whole vibe. πŸ’€

The application data is not included when dumping the session with i2d_SSL_SESSION(3) (and all functions indirectly calling the dump functions like PEM_write_SSL_SESSION(3) and PEM_write_bio_SSL_SESSION(3)) β€” and can therefore not be restored.

so like… you dump the session, your data ghosts you. gone. ✨poof✨ no cap, it does not come back 😭


πŸ”₯ SEE ALSO πŸ”₯


πŸ‘‘ HISTORY πŸ‘‘

SSL_SESSION_get_ex_new_index(), SSL_SESSION_set_ex_data(), and SSL_SESSION_get_ex_data() first appeared in SSLeay 0.9.0 and have been available since OpenBSD 2.4. literal elders of the game, we stan 🫢✨


and that's the whole page bestie! 🌈 this little number is from the Debian edition, dated June 8, 2025, and the manual tag on the door says SSL_SESSION_GET_EX_NEW_INDEX(3) β€” slay, go forth and register your indexes responsibly πŸ’…πŸŽ€

πŸ“¦ where this page comes from