gnutls_certificate_get_x509_key(3)

πŸ’– gnutls_certificate_get_x509_key(3) πŸ’–

okay bestie, so this is a page out of the gnutls manual β€” yes, that gnutls β€” and it's all about yoinking an X.509 private key back out of your credentials. grab a strawberry milk, we're doing this πŸ“


✨ NAME ✨

gnutls_certificate_get_x509_key β€” it's an API function, and it's giving "give me back my key" energy πŸ’…


🌸 SYNOPSIS 🌸

#include <gnutls/gnutls.h>

int gnutls_certificate_get_x509_key(gnutls_certificate_credentials_t
res, unsigned index, gnutls_x509_privkey_t * key);

πŸŽ€ ARGUMENTS πŸŽ€

  • gnutls_certificate_credentials_t res β€” this is a gnutls_certificate_credentials_t type, bestie. it's the credentials holder, the lil container everything lives in 🫢
  • unsigned index β€” the index of the key you wanna obtain. like which one. the number. the vibe check position πŸ”’
  • gnutls_x509_privkey_t * key β€” location to store the key. you're handing it a place to put the key, and it will put the key there ✨

πŸ’œ DESCRIPTION πŸ’œ

So what does it do. It obtains an X.509 private key that has been stored in res β€” and no cap, that key had to get in there somehow, via one of these:

  • gnutls_certificate_set_x509_key()
  • gnutls_certificate_set_key()
  • gnutls_certificate_set_x509_key_file()
  • gnutls_certificate_set_x509_key_file2()
  • gnutls_certificate_set_x509_key_mem()
  • gnutls_certificate_set_x509_key_mem2()

The returned key must be deallocated with gnutls_x509_privkey_deinit() when no longer needed. not optional, not "eh I'll get to it", fr fr β€” clean up after yourself 🧚

The index matches the return value of gnutls_certificate_set_x509_key() and friends functions, when the GNUTLS_CERTIFICATE_API_V2 flag is set. so like, the number you got back from the setter is the number you feed in here. iykyk 😌

🚨 and now the sad part: If there is no key with the given index, GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE is returned. If the key with the given index is not a X.509 key, GNUTLS_E_INVALID_REQUEST is returned. πŸ’€

⭐ RETURNS ⭐

GNUTLS_E_SUCCESS (0) on success β€” slay β€” or a negative error code. so if it's negative, that's a no from her πŸ™ˆ


πŸ¦‹ SINCE πŸ¦‹

3.4.0 β€” a classic, been iconic since way back πŸ‘‘


🌈 REPORTING BUGS 🌈

Found a bug? Tell the gnutls girlies:


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. (yes that's the whole thing, verbatim, no edits, periodt ✨)


πŸ”₯ 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!! this was gnutls manual, version 3.8.13, from the gnutls gnutls_certificate_get_x509_key(3) page β€” go forth, get your keys, deinit them after. mwah πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from