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 agnutls_x509_crt_ttype. 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 ofbuf. 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 casebuf_sizegets 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,
0is 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 π
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
- alpine 3.22: gnutls-doc 3.8.13-r0 Β· LGPL-2.1-or-later
- alpine 3.23: gnutls-doc 3.8.13-r0 Β· LGPL-2.1-or-later
- alpine 3.24: gnutls-doc 3.8.13-r0 Β· LGPL-2.1-or-later
- arch rolling: gnutls 3.8.13-3 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 43: gnutls-devel 3.8.13-1.fc43 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 43: gnutls-devel 3.8.13-1.fc43 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 44: gnutls-devel 3.8.13-1.fc44 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 44: gnutls-devel 3.8.13-1.fc44 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- ubuntu stonking: gnutls-doc 3.8.13-1ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms