gnutls_x509_cr...key_purpose_oid(3)

✨ NAME ✨

gnutls_x509_crt_get_key_purpose_oid β€” okay bestie this is an API function, and it lives in the gnutls manual (section 3, the library-functions girlies πŸ’…). Let's get into it.


🌸 SYNOPSIS 🌸

#include <gnutls/x509.h>

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

πŸŽ€ ARGUMENTS πŸŽ€

  • gnutls_x509_crt_t cert β€” should contain a gnutls_x509_crt_t type. Yes literally, that's the whole vibe. It's the cert we're digging through πŸ”
  • unsigned indx β€” this tells us which OID to hand back. Use (0) to get the very first one, because of course we start at zero, it's giving classic C energy 😌
  • void * oid β€” a pointer to a buffer that's gonna hold the OID. And plot twist: it may be null 🫒
  • size_t * oid_size β€” initially holds the size of oid. Like, you come in with the size, that's the deal.
  • unsigned int * critical β€” output flag, tells you whether the extension is critical or not. Important-girlie detector, lowkey πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

So this function extracts the key purpose OIDs of the Certificate you specified, at the index you gave it. Slay.

Where do these live? They're stored in the Extended Key Usage extension, a.k.a. 2.5.29.37 (yes the iconic number, write it down). And if you want human readable names instead of raw OID crumbs, go peek at the GNUTLS_KP_* definitions ✨

Now, the important bit, don't skip this:

If oid is null then only the size will be filled. So you can do the classic two-step: ask for the size, then come back with a big enough buffer. Main character planning energy fr fr.

Also the oid you get back will be null terminated, BUT β€” and this is the sneaky part πŸ™ˆ β€” oid_size does not account for that trailing null. So budget accordingly bestie, don't get caught slipping.


πŸ’– RETURNS πŸ’–

  • GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer you provided isn't long enough 😭 and in that case *oid_size gets updated with the size you actually needed. So it's not a fail-fail, it's a "here's the tea, try again" moment.
  • On success, 0 is returned. Periodt. βœ…

πŸ› REPORTING BUGS πŸ›

Found a bug? Don't suffer in silence, tell the devs:


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, share it, remix it, keep the receipt (the notice) attached 🫢


🌈 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, every flag, every arg, every caveat, untouched. This was the gnutls manual, version 3.8.13, page gnutls_x509_cr...key_purpose_oid(3). Go forth and read your cert extensions, you absolute legend πŸ’œβœ¨

πŸ“¦ where this page comes from