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 agnutls_psk_server_credentials_ttype. (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
usernameandkey ->datamust be allocated usinggnutls_malloc(). notmalloc, notcalloc, not vibes.gnutls_malloc(). periodt. π - the
usernameshould 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
0on success.-1indicates 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:
- Report bugs to <bugs@gnutls.org>.
- Home page: https://www.gnutls.org
π COPYRIGHT π
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
- alpine 3.22: gnutls-doc 3.8.13-r0 Β· LGPL-2.1-or-later
- alpine 3.23: gnutls-doc 3.8.13-r0 Β· LGPL-2.1-or-later
- alpine 3.24: gnutls-doc 3.8.13-r0 Β· LGPL-2.1-or-later
- arch rolling: gnutls 3.8.13-3 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 43: gnutls-devel 3.8.13-1.fc43 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 43: gnutls-devel 3.8.13-1.fc43 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 44: gnutls-devel 3.8.13-1.fc44 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 44: gnutls-devel 3.8.13-1.fc44 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- ubuntu stonking: gnutls-doc 3.8.13-1ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms