gnutls_psk_set...tials_function3(3)
β¨ gnutls_psk_set_server_credentials_function3 β¨
okay bestie, gather round, because we're doing gnutls internals today and honestly? it's giving β¨server-side PSK vibesβ¨. this page lives in the gnutls manual, and it's literally just one lil API function that you're about to become obsessed with. π
πΈ NAME πΈ
gnutls_psk_set_server_credentials_function3 β an API function, no cap. that's the whole name. she's long, she's specific, she ate. π
π SYNOPSIS π
first things first, you gotta bring in the header:
#include <gnutls/gnutls.h>
and here's the signature, character for character, don't you dare touch it:
void
gnutls_psk_set_server_credentials_function3(gnutls_psk_server_credentials_t
cred, gnutls_psk_server_credentials_function3 func);
yes she's a void girlie. she returns nothing. she just does things. π
π¦ ARGUMENTS π¦
two args, both important, let's go:
gnutls_psk_server_credentials_t credβ this is agnutls_psk_server_credentials_ttype. your creds. your whole identity bestie.gnutls_psk_server_credentials_function3 funcβ this is the callback function. the actual little worker bee that goes and fetches stuff when the handshake asks nicely. π
π DESCRIPTION π
so what does this actually do? this function lets you set a callback that retrieves the user's PSK credentials. that's the tea. β
the callback's function form is, exactly:
int
(*callback)(gnutls_session_t, const gnutls_datum_t* username,
gnutls_datum_t* key, gnutls_psk_key_flags *flags);
now β this callback has the same semantics as gnutls_psk_set_server_credentials_function2(), except it also returns flags associated with the key. that's the glow-up between v2 and v3, and we love an upgrade arc. π
also, the callback may import external PSK using the method described in RFC 9258 by using gnutls_psk_format_imported_identity(). iykyk.
here's the important part, don't skip it:
usernamecontains the actual username.keymust be filled in usinggnutls_malloc(). must. notmalloc, not vibes,gnutls_malloc(). π
and if the callback returns a negative number, gnutls will assume the username does not exist. like, ghosted. π»
heads up: the callback function will only be called once per handshake. one shot, one opportunity. π€
return values? the callback should return 0 on success, while -1 indicates an error. that's it. that's the contract. periodt. β¨
π REPORTING BUGS π
found a bug? spill it, but professionally:
- 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.
π 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 shipped as part of gnutls 3.8.13 β go forth, set your callback, fill that key with gnutls_malloc(), 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