gnutls_credentials_set(3)
π gnutls_credentials_set(3) β the gnutls girlies' guide π
okay bestie, pull up a chair, we're looking at a page from the gnutls manual and it's literally the one that hands your session its little identity β¨
πΈ NAME πΈ
gnutls_credentials_set β the API function, she's the moment π
β¨ SYNOPSIS β¨
#include <gnutls/gnutls.h>
int gnutls_credentials_set(gnutls_session_t session,
gnutls_credentials_type_t type, void * cred);
π ARGUMENTS π
gnutls_session_t sessionβ yeah so this is agnutls_session_ttype, that's the vibe π¦gnutls_credentials_type_t typeβ this is the type of the credentials, like which flavour we're settingvoid * credβ and these are the actual credentials you're setting, the goods π
π DESCRIPTION π
So like, what she does is: she sets the needed credentials for the specified type. E.g. username, password β or public and private keys etc. Obsessed.
The cred parameter is a structure that depends on the specified type and on the current session (client or server). Important. Only a single cred may be set for each different type, and lowkey if you call her again with the same type, she just replaces the previously set credentials. No drama, she just swaps it out π«Ά
Now the part that's giving β¨memory managementβ¨: in order to minimize memory usage, and share credentials between several threads, gnutls keeps a pointer to cred, and not the whole cred structure. So no cap β you have to keep that structure allocated until you call gnutls_deinit(), or until a future call of gnutls_credentials_set() with the same type replaces the cred structure. Don't let her dangle, bestie π
And here's the tea on which struct goes with which type:
- For
GNUTLS_CRD_ANON,credshould begnutls_anon_client_credentials_tin case of a client. In case of a server it should begnutls_anon_server_credentials_t. - For
GNUTLS_CRD_SRP,credshould begnutls_srp_client_credentials_tin case of a client, andgnutls_srp_server_credentials_t, in case of a server. - For
GNUTLS_CRD_CERTIFICATE,credshould begnutls_certificate_credentials_t.
pick the right one or it's giving chaos π§
π₯ RETURNS π₯
On success, GNUTLS_E_SUCCESS (0) is returned β slay. Otherwise a negative error code is returned π
π REPORTING BUGS π
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/
okay that's the whole page, you ate that π this one's from the gnutls 3.8.13 manual, page gnutls_credentials_set(3), 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