gnutls_certificate_get_ours(3)

πŸ’– gnutls_certificate_get_ours(3) πŸ’–

okay bestie, so this one lives in the gnutls manual (you know, the TLS library that's literally carrying the whole internet on its back πŸ’…) and it's all about grabbing your own certificate back out of a session. let's get into it 🫢


✨ SYNOPSIS ✨

#include <gnutls/gnutls.h>

const gnutls_datum_t * gnutls_certificate_get_ours(gnutls_session_t
session);

like, one function, one argument, one pointer. clean. iconic. no notes. πŸ‘‘


πŸŽ€ ARGUMENTS πŸŽ€

  • gnutls_session_t session β€” bestie this is just a gnutls session. that's the whole vibe. hand it your session and it'll do the thing.

🌸 DESCRIPTION 🌸

so the tea is: this function gets the certificate as sent to the peer in the last handshake. πŸ“€

and it comes back in raw (DER) format, which β€” ngl β€” is giving "not human readable, don't even try to read it with your eyes". 🧚

also important: no certificate list is being returned. Only the first certificate. that's it. that's the whole drop. no chain, no extras, just the first one. πŸ™ˆ

here's the part you actually need to remember though, and it's lowkey a plot twist: this function returns the certificate that was sent in the current handshake. in subsequent resumed sessions, this function will return NULL. πŸ’€

and yeah, that differs from gnutls_certificate_get_peers(), which always returns the peer's certificate used in the original session. so they are not the same, bestie, don't mix them up, i'm begging 😭


⭐ RETURNS ⭐

a pointer to a gnutls_datum_t containing our certificate, or NULL in case of an error or if no certificate was used. that's the whole returns situation. if you get NULL, it's not a vibe, but it's also not a mystery. 🌈


πŸ¦‹ REPORTING BUGS πŸ¦‹

found a bug? don't suffer in silence, tell the people:


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 like, go off, just keep the receipts. 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/

not me ending this by saying: if your resumed session hands you NULL, that's not a bug, that's just the documented behaviour, bestie. don't @ me. πŸ™ˆ

mwah πŸ’œ that was the gnutls manual, version 3.8.13, page gnutls_certificate_get_ours(3). go read the cert, you icon. πŸŽ€βœ¨

πŸ“¦ where this page comes from