gnutls_certificate_get_peers(3)

πŸ’– gnutls_certificate_get_peers β€” an API function, bestie πŸ’–

okay so this is a page from the gnutls manual, and today's main character is gnutls_certificate_get_peers. she's an API function. she's lowkey iconic. let's get into it πŸ¦‹


✨ SYNOPSIS ✨

#include <gnutls/gnutls.h>

const gnutls_datum_t * gnutls_certificate_get_peers(gnutls_session_t
session, unsigned int * list_size);

like, yes, that's the whole vibe. one include, one function, two arguments, periodt πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • gnutls_session_t session β€” it's a gnutls session. that's it, that's the girl. she's the session you're working with 🌸
  • unsigned int * list_size β€” this is where the length of the certificate list goes. and no cap, this one may be NULL, so if you don't care about the size you can literally just pass NULL and move on πŸ™ˆ

🌈 DESCRIPTION 🌈

okay so what does she actually do. she gets you the peer's raw certificate (chain) β€” the one the peer sent, exactly as sent. and when we say raw, we mean raw format (that's DER encoded for X.509). it's giving unprocessed, no filter, the original πŸ‘‘

so in the case of an X.509, there may be a certificate list present. and here's the tea: the list is provided as sent by the server. the server is supposed to send its own certificate as the first certificate in the list, then the issuer's certificate after it, then the issuer's issuer, etc. β€” a cute little lineage, very ancestral, very lineage-tracking ✨

but πŸ’€ some servers literally violate this principle, so on certain occasions this may be an unsorted list. so don't come for the ordering, okay? it's not her fault, it's the server's.

and then β€” this is important β€” in resumed sessions, this function will return the peer's certificate list as used in the first/original session. so it's not re-asking the peer, it's remembering. nostalgia core fr fr πŸ₯Ή


πŸ’œ RETURNS πŸ’œ

she returns a pointer to a gnutls_datum_t that contains the peer's certificates. or NULL in case of an error, or if no certificate was used. so like, NULL = something went wrong OR there was simply no cert. either way, check before you dereference, bestie, i'm begging 🫢


😭 REPORTING BUGS 😭

found a bug? spill it 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 yes, you can share this around, just keep the receipts, okay? πŸ’–)


πŸ¦‹ 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, go visit:

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

and that's the whole page, bestie πŸŽ€ this was gnutls_certificate_get_peers, part of the gnutls manual, version 3.8.13. go read your peer's certs responsibly, mwah πŸ’…βœ¨

πŸ“¦ where this page comes from