gnutls_session_get_id(3)

πŸ’– gnutls_session_get_id β€” the vibe check on your session's ID πŸ’–

okay bestie, we're in the gnutls manual, and today's main character is gnutls_session_get_id. it's an API function, it's giving "tell me who this session thinks it is", and we're gonna go through it together. no gatekeeping here 🫢


✨ SYNOPSIS ✨

#include <gnutls/gnutls.h>

int gnutls_session_get_id(gnutls_session_t session, void * session_id,
       size_t * session_id_size);

that's the whole signature, copy it exactly, don't freestyle it πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • gnutls_session_t session β€” literally just a gnutls_session_t type. that's it. that's the vibe. it's the session you're interrogating πŸ”
  • void * session_id β€” a pointer to the space that's gonna hold the session id. bring your own buffer, bestie, this function does not provide one for you 😭
  • size_t * session_id_size β€” okay so on the way in, this needs to already contain the max session_id size you've got room for. on the way out, it gets updated. so it's a little in-and-out queen πŸ‘‘

🌸 DESCRIPTION 🌸

so it returns the TLS session identifier. plot twist though: the session ID is picked by the server, not you. and in older versions of TLS it was a unique identifier shared between client and server that was persistent across resumption. cute, right? iconic era. πŸ•°οΈ

but in the latest version of TLS (1.3), or TLS with session tickets, the whole notion of session identifiers is undefined and you genuinely cannot rely on it to uniquely identify sessions across client and server. it's giving "we don't do that anymore". so don't build your whole personality on it πŸ’€

on the client side, this function returns the identifier that the server gave you, and you cannot assume it has any relation to session resumption. like, none. zero. don't assume. πŸ™ˆ

on the server side, this function is guaranteed to return a persistent identifier of the session since GnuTLS 3.6.4 β€” and heads up, that value may not necessarily map into the actual TLS session ID value. before that version, the value could only be considered a persistent identifier under TLS1.2 or earlier and when no session tickets were in use. very specific, very conditional, very "read the fine print" ✨

and the session identifier value that comes back is always less than GNUTLS_MAX_SESSION_ID_SIZE. always. no exceptions. 🌈


πŸ‘‘ RETURNS πŸ‘‘

on success you get GNUTLS_E_SUCCESS (0) back. slay. anything else and it's an error code β€” handle it, don't ignore it, that's not the move bestie 😀


πŸ’Œ REPORTING BUGS πŸ’Œ

found a bug? report it to <bugs@gnutls.org>. they wanna hear about it, fr fr.

home page: https://www.gnutls.org


Copyright Β© 2001-2023 Free Software Foundation, Inc., and others.

copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. so yes you can share it, just keep the receipts πŸ§ΎπŸ’–


πŸ¦‹ SEE ALSO πŸ¦‹

the full documentation for gnutls is maintained as a Texinfo manual. if the /usr/share/doc/gnutls/ directory does not contain the HTML form, visit:

https://www.gnutls.org/manual/

and that's the whole page, bestie!! this one's from gnutls 3.8.13, manual page gnutls_session_get_id(3), and you absolutely ate reading all of it πŸ’…βœ¨ go forth and check your session ids responsibly 🌸🫢

πŸ“¦ where this page comes from