GNUTLS_HANDSHAKE_SET_HOOK_FUNCTION(3)

✨ gnutls_handshake_set_hook_function ✨

okay bestie, this one lives in the gnutls manual, section 3, and it's literally about sneaking a lil callback into the TLS handshake so you can vibe-check every message as it flies by πŸ’…


🌸 NAME 🌸

gnutls_handshake_set_hook_function β€” an API function, and yes she's the main character


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnutls/gnutls.h>

void gnutls_handshake_set_hook_function(gnutls_session_t session,
unsigned int htype, int when, gnutls_handshake_hook_func func);

πŸŽ€ ARGUMENTS πŸŽ€

  • gnutls_session_t session β€” it's a gnutls_session_t type, the session we're hooking into, no cap
  • unsigned int htype β€” the gnutls_handshake_description_t of the message you wanna hook at πŸ‘€
  • int when β€” a GNUTLS_HOOK_* value, depending on when the hook function should get called
  • gnutls_handshake_hook_func func β€” the function to be called, aka the lil bestie that runs when the hook fires

πŸ’– DESCRIPTION πŸ’–

So this function sets a callback that gets called after or before the specified handshake message has been received or generated. It's giving generalization of gnutls_handshake_set_post_client_hello_function(), fr fr.

Wanna call the hook function prior to the message being generated or processed? Use GNUTLS_HOOK_PRE as the when parameter. Wanna call it after? That's GNUTLS_HOOK_POST. And if you want both cases, GNUTLS_HOOK_BOTH has you covered 🫢

This callback must return 0 on success, or a gnutls error code to terminate the handshake. Periodt.

And if you wanna hook at all handshake messages? Just use an htype of GNUTLS_HANDSHAKE_ANY. Slay, catch them all ✨


πŸ’€ WARNING πŸ’€

You should not use this function to terminate the handshake based on client input unless you know what you are doing. Before the handshake is finished there is no way to know if there is a man-in-the-middle attack being performed. 😭

like genuinely bestie, this is not the moment for vibes-based security decisions. know what you're doing or don't do it at all πŸ™ˆ


πŸ› REPORTING BUGS πŸ›

Found a bug? Report it 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 πŸŽ€ that was gnutls version 3.8.13, straight from the gnutls source β€” go forth and hook responsibly, ily 🫢✨

πŸ“¦ where this page comes from