gnutls_psk_set...tials_function3(3)

✨ NAME ✨

gnutls_psk_set_client_credentials_function3 β€” it's an API function bestie, and it's the one that lets you plug in your own lil callback to hand over the PSK username + password for client auth πŸ’– (this page lives in the gnutls manual, section 3, iykyk)


πŸŽ€ SYNOPSIS πŸŽ€

#include <gnutls/gnutls.h>

void
gnutls_psk_set_client_credentials_function3(gnutls_psk_client_credentials_t
cred, gnutls_psk_client_credentials_function3 * func);

πŸ¦‹ ARGUMENTS πŸ¦‹

  • gnutls_psk_client_credentials_t cred β€” okay so the manpage literally says this "is a gnutls_psk_server_credentials_t type." That's what it says, fr fr, so that's what you get. πŸ‘€
  • gnutls_psk_client_credentials_function3 * func β€” this one's the callback function, the lil guy that does the actual work ✨

🌸 DESCRIPTION 🌸

So basically, this function sets up a callback whose whole job is to fetch the username and password for client PSK authentication. That's it, that's the vibe.

The callback's function form is, no cap:

int (*callback)(gnutls_session_t, gnutls_datum_t* username,
gnutls_datum_t* key, gnutls_datum_t* context, gnutls_psk_key_flags
*flags);

This callback has the same semantics as the one in gnutls_psk_set_client_credentials_function2(), except β€” plot twist β€” it also returns flags associated with the key πŸ‘‘. And the callback is allowed to import an external PSK using the method described in RFC 9258 by calling gnutls_psk_format_imported_identity(). Iconic behaviour, honestly.

Now for the rules, and bestie these are not optional πŸ™ˆ:

  • The data field of username, key, and context must be allocated using gnutls_malloc().
  • The username should be an ASCII string or a UTF-8 string. If you're going the UTF-8 route, it's recommended that it follows the PRECIS framework for usernames (rfc8265). Do with that what you will πŸ’…

Also important: the callback function will be called once per handshake. Every single time. It's committed like that.

And the return value? The callback function should return 0 on success. -1 indicates an error. Simple as.

⚠️ Lowkey do not forget the gnutls_malloc() thing. That's a real requirement, not a suggestion, and I'm not gonna let you fumble it.

😭 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.

(Yes bestie, that means you can share it. Slay.)


🌈 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/

That's the whole page, you ate it 🫢 This was brought to you by gnutls, version 3.8.13, and the page name gnutls_psk_set...tials_function3(3) β€” yes the title is abbreviated like that, it's giving mysterious, we love her for it πŸ’…βœ¨

πŸ“¦ where this page comes from