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 agnutls_certificate_credentials_ttype, 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 withgnutls_x509_crt_deinit(), and the list itself must be freed withgnutls_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_AVAILABLEback - 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 π
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
- 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