GNUTLS_PSK_SET_CLIENT_CREDENTIALS_FUNCTION(3)

πŸ’… gnutls_psk_set_client_credentials_function β€” the glow-up your PSK client needed

okay so bestie, welcome to the gnutls manual, and today we're learning about gnutls_psk_set_client_credentials_function, which is, no exaggeration, the API function that lets your client go "hey, here's my username and my secret" without you having to hardcode anything. iconic behavior. πŸŽ€


✨ NAME ✨

gnutls_psk_set_client_credentials_function β€” API function

like literally it's just that. that's the name. we love a straightforward queen. πŸ‘‘


🌸 SYNOPSIS 🌸

#include <gnutls/gnutls.h>

void
gnutls_psk_set_client_credentials_function(gnutls_psk_client_credentials_t
cred, gnutls_psk_client_credentials_function * func);

yes the signature wraps across two lines, that's just how it is, don't come for me, copy it exactly. πŸ’–


πŸ¦‹ ARGUMENTS πŸ¦‹

  • gnutls_psk_client_credentials_t cred β€” this is a gnutls_psk_server_credentials_t type. (yes, i know, the manpage really does say server credentials type for a client credentials param. i don't make the rules, i just report them faithfully, bestie. πŸ’€)
  • gnutls_psk_client_credentials_function * func β€” this is the callback function. the whole point of the operation. the main character. 🌟

πŸ’œ DESCRIPTION πŸ’œ

so here's the tea: this function is how you set a callback that goes and retrieves the username and password for client PSK authentication. instead of you handing over the secrets up front, you hand over a function that knows how to fetch them. delegation! we love to see it. πŸ™ˆ

the callback's function form is:

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

okay now the important bits, don't skip these, fr fr:

  • the username and key ->data must be allocated using gnutls_malloc(). not malloc, not calloc, not vibes. gnutls_malloc(). periodt. πŸ’…
  • the username should be an ASCII string or a UTF-8 string. and if it's a UTF-8 string, it's recommended to follow the PRECIS framework for usernames (rfc8265). fancy! ✨
  • the callback function will be called once per handshake. one and done, no spam. πŸ•ŠοΈ
  • the callback function should return 0 on success. -1 indicates an error. that's it, that's the whole scoring system. πŸ”₯

😭 REPORTING BUGS 😭

found a bug? don't suffer in silence, bestie, tell the devs:


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 like, go forth, share, remix, 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 was gnutls version 3.8.13, and honestly? she ate. πŸ’–βœ¨πŸŒΈ no cap, go set that callback, allocate with gnutls_malloc(), return your zeros and your minus-ones responsibly, and slay your handshake. mwah. πŸŽ€πŸ’œπŸ¦‹

πŸ“¦ where this page comes from