gnutls_pkcs7_get_crt_raw2(3)

πŸ’– gnutls_pkcs7_get_crt_raw2(3) β€” the gnutls manual, bestie edition πŸ’–

okay so real talk, this is a page from the gnutls manual and it's about pulling one (1) single certificate out of a PKCS7 pile. let's get into it πŸŽ€


✨ NAME ✨

gnutls_pkcs7_get_crt_raw2 β€” API function πŸ’… (yes that's literally all it says, it's an API function, she's mysterious like that)


🌸 SYNOPSIS 🌸

#include <gnutls/pkcs7.h>

int gnutls_pkcs7_get_crt_raw2(gnutls_pkcs7_t pkcs7, unsigned indx,
gnutls_datum_t * cert);

that's the whole vibe, no cap ✨


πŸ¦‹ ARGUMENTS πŸ¦‹

  • gnutls_pkcs7_t pkcs7 β€” bestie, this one should contain a gnutls_pkcs7_t type. that's it, that's the requirement πŸ’œ
  • unsigned indx β€” it contains the index of the certificate to extract, so like, which one you want out of the pile πŸ”’
  • gnutls_datum_t * cert β€” this will hold the contents of the certificate. ⚠️ and listen, it must be deallocated with gnutls_free() β€” don't you dare leak her, that's not the move 🫢

πŸ‘‘ DESCRIPTION πŸ‘‘

so this function will return a certificate of the PKCS7 or RFC2630 certificate set. iconic behaviour, honestly πŸŽ€

and here's the important part: after the last certificate has been read GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned. so when you hit the end she tells you it's the end. no guessing games πŸ’…


πŸ’€ RETURNS πŸ’€

On success, GNUTLS_E_SUCCESS (that's 0, the beautiful zero ✨) is returned, otherwise you get a negative error value. boo. 😭

and if the provided buffer is not long enough, then certificate_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER is returned. so she's like "okay here's how much space I actually need, try again" πŸ’–


⭐ SINCE ⭐

3.4.2 β€” vintage, but still eating πŸ“


πŸ™ˆ REPORTING BUGS πŸ™ˆ

found a bug? Report bugs to <bugs@gnutls.org>. she reads her emails fr fr πŸ“§

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. β€” free as in freedom and also free as in slay πŸ‘‘


🧚 SEE ALSO 🧚

The full documentation for gnutls is maintained as a Texinfo manual. and if the /usr/share/doc/gnutls/ directory does not contain the HTML form, go visit:

https://www.gnutls.org/manual/

like, go read it, it's giving ✨


heads up bestie: if that cert buffer is shorter than the cert, you're getting GNUTLS_E_SHORT_MEMORY_BUFFER and certificate_size gets updated, so check it and come back. and always gnutls_free() at the end. iykyk πŸ’…

k bye that's the whole page πŸ’– this was gnutls 3.8.13, gnutls_pkcs7_get_crt_raw2(3), mwah 😘 πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from