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 a gnutls_certificate_credentials_t type. 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 a gnutls_x509_privkey_t key. 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 Β© 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