GNUTLS_PSK_SET_SERVER_CREDENTIALS_FUNCTION(3)

✨ NAME ✨

gnutls_psk_set_server_credentials_function β€” it's an API function, bestie, and it's the one that lets you plug your own little callback into the server side of PSK stuff πŸ’…

It lives in the gnutls manual, and we're reading the page for version 3.8.13 today. Okay so let's get into it πŸŽ€


🌸 SYNOPSIS 🌸

#include <gnutls/gnutls.h>

void
gnutls_psk_set_server_credentials_function(gnutls_psk_server_credentials_t
cred, gnutls_psk_server_credentials_function * func);

πŸ’– ARGUMENTS πŸ’–

  • gnutls_psk_server_credentials_t cred β€” is a gnutls_psk_server_credentials_t type. yes literally that, it's the creds object you're attaching stuff to 🫢
  • gnutls_psk_server_credentials_function * func β€” is the callback function. the star of the show, the main character, the one doing the actual work πŸ‘‘

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this is the moment. You can use this function to set a callback that retrieves the user's PSK credentials. That's it. That's the job. And the callback's function form is, and I'm quoting this exactly because it matters:

int (*callback)(gnutls_session_t, const char* username, gnutls_datum_t* key);

So username contains the actual username β€” like the real one, the one that came in. And the key must be filled in using the gnutls_malloc(). Not regular malloc, not vibes, gnutls_malloc(). periodt πŸ’€

In case the callback returned a negative number then gnutls will assume that the username does not exist. So a negative return is lowkey a "who? never heard of her" from your own code.

The callback function will only be called once per handshake. One shot, one opportunity, no do-overs πŸ™ˆ

And the return rules are simple: the callback function should return 0 on success, while -1 indicates an error. slay, that's it 🌈


😭 REPORTING BUGS 😭

Found something cursed? Report bugs to <bugs@gnutls.org>. They wanna hear 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. (iconic behaviour honestly, very generous of them πŸ’œ)


🌟 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 was gnutls 3.8.13 β€” the manual page for gnutls_psk_set_server_credentials_function, straight from the gnutls crew. go forth and fill in that key with gnutls_malloc() like the legend you are πŸ’…πŸ¦‹πŸ“

πŸ“¦ where this page comes from