GNUTLS_X509_CRT_GET_EXTENSION_OID(3)

πŸ’– gnutls_x509_crt_get_extension_oid β€” the manual page bestie πŸ’–

okay so real talk, this is the gnutls_x509_crt_get_extension_oid page from the gnutls manual (yes the whole gnutls thing, we love her), and it's genuinely so useful. sit down, grab a strawberry πŸ“, and let's get into it.


✨ NAME ✨

gnutls_x509_crt_get_extension_oid β€” it's an API function, bestie. that's the whole name section. iconic of her honestly.


🌈 SYNOPSIS 🌈

first things first, you gotta pull in the header:

#include <gnutls/x509.h>

and here's the signature, exactly as it lives:

int gnutls_x509_crt_get_extension_oid(gnutls_x509_crt_t cert, unsigned
       indx, void * oid, size_t * oid_size);

no cap, that's it. four args, one int coming back at you. πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

okay let's meet the cast, one by one:

  • gnutls_x509_crt_t cert β€” this one "should contain a gnutls_x509_crt_t type". that's the cert you're interrogating, she's the main character of this whole operation πŸ‘‘
  • unsigned indx β€” this says which extension OID you wanna send. and listen, use (0) to get the first one. zero-indexed, as always, the way the universe intended.
  • void * oid β€” a pointer to a structure that's gonna hold the OID. and yes, it may be null. (sometimes you just wanna know the size first, we see you, we respect the strategy 🫢)
  • size_t * oid_size β€” this one initially holds the size of oid. so you tell it how big your buffer is, and it does its thing.

πŸ¦‹ DESCRIPTION πŸ¦‹

so what does this function actually do? it returns the requested extension OID from inside the certificate. that's the whole vibe. the extension OID gets stored as a string in the buffer you provided. slay.

and here's the lil detail that gets people every time: the oid that comes back will be null terminated β€” but the oid_size will not account for that trailing null. so she's null-terminated but the size doesn't count the null. not me being obsessed with this detail. lowkey crucial, iykyk. πŸ’€


⭐ RETURNS ⭐

on success? GNUTLS_E_SUCCESS (0) is returned. that's the good ending, we love to see it. 🌸

otherwise you get a negative error code back. sad girl hours.

and listen, if you've reached the last extension available, GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE gets returned. that's not a bug bestie, that's just the end of the list. you ran out of extensions. it happens to everyone. πŸ™ˆ


😭 REPORTING BUGS 😭

found something broken? spill it, but nicely, to the actual humans:

Report bugs to <bugs@gnutls.org>.

Home page: https://www.gnutls.org


Copyright Β© 2001-2023 Free Software Foundation, Inc., and others.

and the license tea: 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, take it, share it, just keep the receipts. periodt. ✨


πŸ’œ SEE ALSO πŸ’œ

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

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

that's your next stop, bestie, go read more. 🧚


ngl, if you're looping through extensions, remember: start at (0), pass a null oid if you just need the size, and expect GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE when you hit the end. that's the whole strategy. πŸ’…

and that's the page!! this was gnutls_x509_crt_get_extension_oid(3) from the gnutls manual, version 3.8.13, brought to you by the lovely folks at the Free Software Foundation. thanks for reading, ily, go write some good C πŸ«ΆπŸ’–πŸŒˆ

πŸ“¦ where this page comes from