gnutls_psk_set...tials_function2(3)

πŸ’– gnutls_psk_set_server_credentials_function2 β€” like, the PSK server callback setter, but make it non-string ✨

okay bestie, welcome to the gnutls manual page for gnutls_psk_set_server_credentials_function2, which is an API function 🫢. this is the one where you tell your server how to look up PSK creds for a user β€” and unlike its sibling, it does not force usernames to be strings. iykyk. πŸ’…


✨ SYNOPSIS ✨

#include <gnutls/gnutls.h>

void
gnutls_psk_set_server_credentials_function2(gnutls_psk_server_credentials_t
cred, gnutls_psk_server_credentials_function2 func);

like, that's the whole vibe. one include, one function, two args. slay. πŸŽ€


🌸 ARGUMENTS 🌸

  • gnutls_psk_server_credentials_t cred β€” bestie this is literally a gnutls_psk_server_credentials_t type. that's it, that's the arg. πŸ‘‘
  • gnutls_psk_server_credentials_function2 func β€” and this one is the callback function. the star of the show. the main character. 🌟

πŸ’œ DESCRIPTION πŸ’œ

so here's the tea: you can use this function to set a callback that retrieves the user's PSK credentials. literally that's its whole job. πŸ“

the callback's function form is:

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

now, this callback function has the same semantics as the one from gnutls_psk_set_server_credentials_function(), BUT β€” and this is the iconic part β€” it lets you use non-string usernames. no cap. πŸ™ˆ

  • username contains the actual username. yes, fr fr, the real one.
  • the key must be filled in using gnutls_malloc(). do not freestyle this, bestie, use gnutls_malloc(). 😭
⚠️ warning time: if the callback returns a negative number, gnutls will just assume the username does not exist. like, ghosted. πŸ’€

also, the callback function will only be called once per handshake β€” so don't be out here expecting it to spam-call you, it's a one-and-done situation. ✨

return values, bestie, get them right:

  • return 0 on success πŸ’–
  • return -1 to indicate an error 😭

πŸ”₯ REPORTING BUGS πŸ”₯

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


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. periodt. πŸ’…


πŸ¦‹ 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, go visit:

https://www.gnutls.org/manual/


and that's a wrap on the gnutls manual, version 3.8.13, dated 3.8.13 πŸ’–βœ¨ go forth and set your PSK server credentials callbacks, bestie, you're gonna ate. πŸŽ€πŸ«ΆπŸŒˆ

πŸ“¦ where this page comes from