GNUTLS_CERTIFICATE_SET_RETRIEVE_FUNCTION(3)
π NAME π
gnutls_certificate_set_retrieve_function β bestie, it's an API function, and it's the one that tells gnutls who to ask when it needs a certificate mid-handshake π
This page lives in the gnutls manual, and we're serving it up fresh β¨
πΈ SYNOPSIS πΈ
#include <gnutls/gnutls.h>
void
gnutls_certificate_set_retrieve_function(gnutls_certificate_credentials_t
cred, gnutls_certificate_retrieve_function * func);
β¨ ARGUMENTS β¨
gnutls_certificate_credentials_t credβ okay so this is agnutls_certificate_credentials_ttype. That's the whole lore, she's just the creds babe πgnutls_certificate_retrieve_function * funcβ and this one? It's the callback function. The main character of this whole story π
π¦ DESCRIPTION π¦
So the way this works: this function sets a callback that gets called to retrieve the certificate that's gonna be used in the handshake. Not me hyping up a callback but honestly? Iconic behavior β¨
The callback will take control only if a certificate is requested by the peer. No request, no callback, that's the rule bestie.
And listen β you are advised to use gnutls_certificate_set_retrieve_function2() instead, because it is much more efficient in the processing it requires from gnutls. Lowkey that's a glow-up, take the hint π
The callback's function prototype is:
int (*callback)(gnutls_session_t,
const gnutls_datum_t* req_ca_dn,
int nreqs,
const gnutls_pk_algorithm_t* pk_algos,
int pk_algos_length,
gnutls_retr2_st* st);
Let's break down the cast of characters, because they all matter:
req_ca_dnis only used in X.509 certificates. It contains a list with the CA names that the server considers trusted. This is a hint, and typically the client should send a certificate that is signed by one of these CAs. These names, when available, are DER encoded. To get a more meaningful value, use the functiongnutls_x509_rdn_get()πpk_algoscontains a list with the server's acceptable public key algorithms. The certificate you return should support the server's given algorithms β no cap, she's picky about who she talks to πstshould contain the certificates and private keys π
If the callback function is provided, then gnutls will call it, in the handshake, after the certificate request message has been received. Timing is everything bestie β°
In server side, pk_algos and req_ca_dn are NULL. Yeah, they just ghost you over there π
Now the rules of the game:
- The callback function should set the certificate list to be sent, and return
0on success β - If no certificate was selected, then the number of certificates should be set to zero
- The value
(-1)indicates error, and the handshake will be terminated π¨ (so like, be careful, that's the dramatic one) - If both certificates are set in the credentials and a callback is available, the callback takes predence. Callback wins, she ate and left no crumbs π
β SINCE β
3.0 β she's been around, she's a classic, respect the elders π«Ά
π REPORTING BUGS π
Found a bug? Tell the people, they wanna know fr fr:
- 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. That's the deal, and honestly? Generous queen behavior π
π 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, you're officially fluent in certificate retrieve callbacks π β¨
This little masterpiece came from the gnutls manual, version 3.8.13 β go forth, set your callbacks, and slay ππ¦π
π¦ 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