gnutls_certificate_set_key(3)
π gnutls_certificate_set_key π
okay bestie, sit DOWN, because we're diving into a gnutls manual page β yes, the gnutls one, from the gnutls manual, page gnutls_certificate_set_key(3) β and this one is literally about handing your credentials a whole public/private key pair. no cap. it's giving "crypto admin but make it cute". π
β¨ NAME β¨
gnutls_certificate_set_key β API function. that's it, that's the name, and yes it does exactly what it says on the tin. π«Ά
πΈ SYNOPSIS πΈ
#include <gnutls/abstract.h>
int gnutls_certificate_set_key(gnutls_certificate_credentials_t res,
const char ** names, int names_size, gnutls_pcert_st * pcert_list, int
pcert_list_size, gnutls_privkey_t key);
look at that signature. six whole arguments. main character energy honestly. π
π¦ ARGUMENTS π¦
gnutls_certificate_credentials_t resβ this is, surprise surprise, agnutls_certificate_credentials_ttype. the whole point of the function, the queen bee, the structure everything gets loaded into. πconst char ** namesβ an array of DNS names that belong to the public-key. if there aren't any, you just passNULL. it's optional, babe. πint names_sizeβ holds the size of thenameslist. gotta tell it how many names you brought. β¨gnutls_pcert_st * pcert_listβ contains a certificate list (aka the chain) or a raw public-key. your pick, both are valid. πint pcert_list_sizeβ holds the size of the certificate list. same deal, count your certs bestie. πgnutls_privkey_t keyβ agnutls_privkey_tkey that corresponds to the first public-key inpcert_list. so like, key β first cert, they're a matched set, they go together. π
π DESCRIPTION π
so what does this actually do? it sets a public/private key pair into the gnutls_certificate_credentials_t type. that's the vibe.
the given public key may be encapsulated in a certificate, or it can just be given as a raw key. either way works.
this function may be called more than once, which is so iconic of it β that's for when multiple key pairs exist for the server. so like, if your server has multiple identities, go off, call it again. π₯
for clients that want to send more than their own end-entity certificate (e.g., also an intermediate CA cert), the full certificate chain must be provided in pcert_list. don't be shy, send the whole chain. πΈ
okay IMPORTANT one: note that thekeywill become part of the credentials structure and must not be deallocated. it will be automatically deallocated when theresstructure is deinitialized. so do NOT free it yourself, bestie, that's a whole situation. π
and another warning, fr fr: if this function fails, the res structure is at an undefined state and it must not be reused to load other keys or certificates. like, it's done. don't touch it. π
now the return-value tea β β by default this function 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). that index can be used for other functions to refer to the added key-pair. so you get a lil ticket number for your key. so handy. ποΈ
and since GnuTLS 3.6.6, this function also handles raw public keys. glow up. β¨
β RETURNS β
on success this functions returns zero, and otherwise a negative value on error β see above if you wanna know how to modify that behavior. (spoiler: it's the GNUTLS_CERTIFICATE_API_V2 thing. you knew that. iykyk.) π
π SINCE π
3.0
like, ancient by internet standards, but make it legacy-supported. π
π REPORTING BUGS π
found something cursed? report bugs to <bugs@gnutls.org>.
home page: https://www.gnutls.org
they wanna hear from you, bestie, don't gatekeep your bug reports. π«Ά
π 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. slay, and legally so. β
π 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/
that's the lore. go read it. π§
and that's the whole page, bestie β gnutls manual, version 3.8.13, page gnutls_certificate_set_key(3). now go forth and set some keys, but do NOT free that key, i'm watching you. π
πΈβ¨
π¦ 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