gnutls_session_get_data2(3)

πŸ’– gnutls_session_get_data2 πŸ’–

okay bestie, gather round, because we're talking about a gnutls function and she is lowkey the whole reason your TLS sessions can come back from the dead like a main character. it's gnutls_session_get_data2, and no cap, she's iconic. let's get into it πŸŽ€


✨ NAME ✨

gnutls_session_get_data2 β€” API function πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnutls/gnutls.h>

int gnutls_session_get_data2(gnutls_session_t session, gnutls_datum_t *
data);

🌸 ARGUMENTS 🌸

  • gnutls_session_t session β€” bestie this is literally just a gnutls_session_t type. that's the vibe. that's the whole assignment. ✨
  • gnutls_datum_t * data β€” a pointer to a datum, and that datum is gonna hold the session. she's the container, the vessel, the it-girl storage unit 🫢

πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the tea: this function returns all the necessary parameters to support resumption. the client should call this function and store the returned session data. then later, a session can be resumed by calling gnutls_session_set_data() with the data you got back. it's giving "save your progress" energy, fr fr πŸ’Ύ

⚠️ heads up though β€” under TLS 1.3, it's recommended for clients to use session parameters only once, to prevent passive-observers from correlating the different connections. do not be reusing that thing like a rewatch, bestie. one and done. πŸ™ˆ

the returned data are allocated and must be released using gnutls_free(). do not forget. do not ghost your memory management. that's not slay, that's a leak πŸ’€

this function will fail if called prior to handshake completion. and in case of false start TLS, the handshake completes only after data have been successfully received from the peer. so like, wait your turn. the handshake is not done until it says it's done. 🌈

under TLS1.3, session resumption is possible only after a session ticket is received by the client. to make sure such a ticket has actually arrived, use gnutls_session_get_flags() and check for flag GNUTLS_SFLAGS_SESSION_TICKET. if this flag is not set, this function will wait for a new ticket within an estimated roundtrip, and if it's not received, it will return dummy data which cannot lead to resumption. it's giving fake ID energy, honestly. it looks valid, it is not valid, do not present it at the club πŸŽŸοΈπŸ’€

to get notified when new tickets are received by the server, use gnutls_handshake_set_hook_function() to wait for GNUTLS_HANDSHAKE_NEW_SESSION_TICKET messages. and each call of gnutls_session_get_data2() after a ticket is received will return session resumption data corresponding to the last received ticket. last one wins, periodt ✨

🫢 note that this function under TLS1.3 requires a callback to be set with gnutls_transport_set_pull_timeout_function() for successful operation. there was a bug before 3.6.10 which could make this function fail if that callback was not set. on later versions, if it's not set, the function will return a successful error code, but will return dummy data that cannot lead to a resumption. so it's smiling at you while lying to you. we've all been there 😭

⭐ RETURNS ⭐

on success, GNUTLS_E_SUCCESS (0) is returned, otherwise an error code is returned. simple. clean. exactly what you'd expect. πŸ’…


πŸ› REPORTING BUGS πŸ›

found a bug? spill. report bugs to <bugs@gnutls.org>.

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.


🌟 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 little baddie is from gnutls 3.8.13 β€” go forth and resume your sessions responsibly, drink water, set your pull timeout callback, and never reuse a TLS 1.3 session parameter twice. mwah πŸ’‹βœ¨πŸ¦‹

πŸ“¦ where this page comes from