gnutls_x509_crt_get_dn_by_oid(3)

πŸ’– gnutls_x509_crt_get_dn_by_oid β€” like, the whole manual page, bestie πŸ’–

okay so this is a page from the gnutls manual β€” you know, the TLS library that's carrying the entire internet on its back, no big deal. and this specific lil function? it's an API function called gnutls_x509_crt_get_dn_by_oid, and it's about pulling one specific piece out of a certificate's Distinguished Name. let's get into it πŸŽ€


✨ SYNOPSIS ✨

#include <gnutls/x509.h>

int gnutls_x509_crt_get_dn_by_oid(gnutls_x509_crt_t cert, const char *
oid, unsigned indx, unsigned int raw_flag, void * buf, size_t *
buf_size);

🫢 ARGUMENTS 🫢

  • gnutls_x509_crt_t cert β€” bestie this one should contain a gnutls_x509_crt_t type. that's the cert you're digging through πŸ’…
  • const char * oid β€” holds an Object Identifier as a null terminated string. yep, the OID goes in as a plain ol' string, null terminated and everything ✨
  • unsigned indx β€” here's the tea: if there are multiple of the same OIDs chillin' in the RDN, this says which one you want. use (0) to grab the first one, obviously πŸ‘‘
  • unsigned int raw_flag β€” if this is non-zero, you get the raw DER data of the DN part. raw. unfiltered. no cap πŸ’€
  • void * buf β€” a pointer to where the DN part gets copied. it may be null! (which is a whole mood, see below) πŸ¦‹
  • size_t * buf_size β€” this starts out holding the size of buf. it's the container size you're offering up πŸŽ€

🌸 DESCRIPTION 🌸

so like, this function extracts the part of the name of the Certificate subject that's specified by the OID you passed in. that's it, that's the job πŸ’–

the output β€” if the raw flag is not used β€” comes back encoded as described in RFC4514. so what you get is a string that's ASCII or UTF-8 encoded, depending on the certificate data. it's giving "whatever the cert says, honestly" 🌈

some helper macros with popular OIDs are hanging out in gnutls/x509.h β€” go say hi 🧚

and here's the important part: if the raw flag is (0), this function will only return known OIDs as text. any other OIDs get DER encoded, exactly as described in RFC4514 β€” that means hex format with a # prefix. if you wanna know whether an OID is a known one, check with gnutls_x509_dn_oid_known(). iykyk πŸ”₯

if buf is null then only the size will be filled. so you can do the lil two-step: ask for the size first, then come back with a buffer that actually fits. main character planning energy, honestly ✨

also!! if the raw_flag is not specified, the output is always null terminated β€” but plot twist: the buf_size will not include the null character. don't let that trip you up bestie 😭


⭐ RETURNS ⭐

  • GNUTLS_E_SHORT_MEMORY_BUFFER β€” your buffer was not long enough. rude, i know. and in that case buf_size gets updated with the required size, so at least you learn what you actually needed πŸ’…
  • GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE β€” there's no data at the current index. like, nothing there. empty. void. it's giving "no thoughts head empty" πŸ™ˆ
  • on success, 0 is returned. slay πŸ‘‘

😭 REPORTING BUGS 😭

found a bug? spill the tea, report it to <bugs@gnutls.org>. they wanna know fr fr.

home page is right here: <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 like β€” go off, redistribute, just keep the receipts 🫢


🌈 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!! every flag, every return code, every # prefix, all of it πŸ’– this came to you from gnutls 3.8.13 β€” iconic, legendary, no notes. now go extract those DNs like the main character you are πŸ‘‘βœ¨πŸ¦‹πŸ’œ
πŸ“¦ where this page comes from