gnutls_certificate_set_x509_key(3)
β¨ NAME β¨
gnutls_certificate_set_x509_key β bestie, this is the API function that pairs up a certificate with its private key, and it lives in the gnutls manual π
πΈ SYNOPSIS πΈ
#include <gnutls/gnutls.h>
int gnutls_certificate_set_x509_key(gnutls_certificate_credentials_t
res, gnutls_x509_crt_t * cert_list, int cert_list_size,
gnutls_x509_privkey_t key);
π ARGUMENTS π
gnutls_certificate_credentials_t resβ okay so this one is literally agnutls_certificate_credentials_ttype. that's the vibe. πgnutls_x509_crt_t * cert_listβ this holds a certificate list (a whole path, bestie, not just one) for the private key you're specifying. π¦int cert_list_sizeβ the size of that certificate list. the count. the number of certs in the list. πgnutls_x509_privkey_t keyβ and this is agnutls_x509_privkey_tkey. the key. the moment. π
π DESCRIPTION π
So what this function does is set a certificate/private key pair inside the gnutls_certificate_credentials_t type. iconic behavior honestly.
It is totally fine to call this function more than once β like, no cap β in case multiple keys/certificates exist for the server. she can hold more than one, she's flexible like that.
For clients that want to send more than just their own end entity certificate (e.g., also an intermediate CA cert, because we love a chain), you put the certificate chain in cert_list. π
β¨ Good news bestie: the certificates and keys you provide can be safely deinitialized after this function is called. you don't have to babysit them. they're fine. π«Ά
π Okay but here's the serious one: if that function fails to load, the res type is at an undefined state, and it must not be reused to load other keys or certificates. Like, do not. no cap. undefined state is not a vibe. π
Also lowkey important: this function by default returns zero on success and a negative value on error. But β since 3.5.6, when the flag GNUTLS_CERTIFICATE_API_V2 is set using gnutls_certificate_set_flags(), it returns an index (greater or equal to zero). And that index can be used by other functions to refer to the added key-pair. so you get a little handle for your little key-pair. precious. π₯Ή
β RETURNS β
On success this function returns zero. Otherwise it returns a negative value on error (peep the description above if you wanna know how to modify that behavior π).
π§ SINCE π§
2.4.0 β she's been here a while. an OG. periodt. π
π REPORTING BUGS π
Found a bug? Report it 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. (translation: share the love, just keep the receipts, bestie π«Ά)
π 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 fr fr π this was the gnutls manual, version 3.8.13 β mwah, go forth and load those key-pairs, bestie β¨ππ
π¦ 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