gnutls_certificate_get_x509_crt(3)

πŸ’– gnutls_certificate_get_x509_crt(3) πŸ’–

okay bestie, welcome to the gnutls manual, this one's a lil API function and it's lowkey iconic. grab a boba, we're doing this ✨


🌸 NAME 🌸

gnutls_certificate_get_x509_crt β€” it's an API function, bestie. that's the whole vibe πŸŽ€


✨ SYNOPSIS ✨

#include <gnutls/gnutls.h>

int gnutls_certificate_get_x509_crt(gnutls_certificate_credentials_t
res, unsigned index, gnutls_x509_crt_t ** crt_list, unsigned *
crt_list_size);

like yes, she's a mouthful, but she's worth it πŸ’…


🫢 ARGUMENTS 🫢

  • gnutls_certificate_credentials_t res β€” bestie this is just a gnutls_certificate_credentials_t type, that's it, that's the arg πŸ’–
  • unsigned index β€” the index of the certificate list you wanna obtain. like which one in the lineup πŸ‘‘
  • gnutls_x509_crt_t ** crt_list β€” this is where the certificate list gets stored. it's the lil basket you're putting them in 🧺
  • unsigned * crt_list_size β€” and this one will hold the number of certificates. so you know how many you got 🌈

πŸ’œ DESCRIPTION πŸ’œ

So what she does: she obtains an X.509 certificate list that has been stored in res β€” and you got it there using one of these cuties:

  • 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()
⚠️ okay important, do NOT forget this: every single certificate in the returned certificate list must be deallocated with gnutls_x509_crt_deinit(), and the list itself must be freed with gnutls_free(). no leaks, we don't do that here πŸ’€

Now, the index β€” it matches the return value of gnutls_certificate_set_x509_key() and her friends functions, but only when the GNUTLS_CERTIFICATE_API_V2 flag is set. iykyk ✨

And the error tea β˜•:

  • if there's no certificate with the given index, you get GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE back
  • if the certificate with the given index is not an X.509 certificate, you get GNUTLS_E_INVALID_REQUEST

And one more time for the people in the back (because it's literally that important): the returned certificates must be deinitialized after use, and the crt_list pointer must be freed using gnutls_free(). periodt πŸŽ€


⭐ RETURNS ⭐

GNUTLS_E_SUCCESS (which is 0) on success πŸ₯³ β€” or a negative error code if it's not your day 😭


πŸ¦‹ SINCE πŸ¦‹

3.4.0 β€” she's been around, she's a legend πŸ‘‘


πŸ™ˆ REPORTING BUGS πŸ™ˆ

Found a bug? spill the tea 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. so basically, do your thing, just keep the receipts πŸ§ΎπŸ’–


🌈 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, no cap πŸ’–βœ¨

this lil slice of perfection is from gnutls 3.8.13, page gnutls_certificate_get_x509_crt(3) β€” mwah, go forth and deinit your certs πŸ«ΆπŸŽ€πŸŒΈ

πŸ“¦ where this page comes from