GNUTLS_X509_CRT_GET_ISSUER_DN_BY_OID(3)

πŸ’– gnutls_x509_crt_get_issuer_dn_by_oid β€” okay bestie, let's read a cert's issuer like it's a group chat πŸ’–

This lil icon lives in the gnutls manual, section 3, and it's an API function. Yes, the gnutls. Sit down, hydrate, we're doing X.509 today. πŸŽ€


✨ NAME ✨

gnutls_x509_crt_get_issuer_dn_by_oid β€” API function

Like. That's the whole name. It's giving "I extract one specific piece of the issuer's distinguished name." Slay.


🌸 SYNOPSIS 🌸

#include <gnutls/x509.h>

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

Six args, one int back. No cap, that's just the signature. πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • gnutls_x509_crt_t cert β€” bestie this should hold a gnutls_x509_crt_t type. That's the cert we're snooping on. πŸ‘‘
  • const char * oid β€” holds an Object Identified in null terminated string. (Yes the original says "Object Identified", we're keeping that energy, it's iconic.) So like, a null-terminated OID string. ✨
  • unsigned indx β€” in case multiple same OIDs exist in the RDN, this says which one you want. Use (0) to get the first one. Zero-indexed, obviously, we love a first-element situation. πŸ™ˆ
  • unsigned int raw_flag β€” if non-zero, returns the raw DER data of the DN part. Raw. Unfiltered. No makeup. πŸ’€
  • void * buf β€” a pointer to a structure to hold the name (may be null). Yes, may be null, that's legal here, it's not a mistake, we'll get to it. 🫢
  • size_t * buf_size β€” initially holds the size of buf. So like, you tell it how much room you brought. πŸŽ€

πŸ’œ DESCRIPTION πŸ’œ

Okay so here's the tea. This function will extract the part of the name of the Certificate issuer specified by the given OID. That's it, that's the job, and it does it flawlessly. πŸ’…

The output, if the raw flag is not used, will be encoded as described in RFC4514. Thus a string that is ASCII or UTF-8 encoded, depending on the certificate data. So the encoding is doing a vibe check on your cert and picking accordingly. ✨

Some helper macros with popular OIDs can be found in gnutls/x509.h. If raw flag is (0), this function will only return known OIDs as text. Other OIDs will be DER encoded, as described in RFC4514 β€” in hex format with a '#' prefix. You can check about known OIDs using gnutls_x509_dn_oid_known(). So if you're getting a #-prefixed hex blob, that's not a bug, that's the function telling you "this OID is not one of the known ones, bestie." πŸ”₯

If buf is null then only the size will be filled. Cute, right? It's like window shopping. If the raw_flag is not specified the output is always null terminated, although the buf_size will not include the null character. That last bit is the trap. The null terminator is a little ghost πŸ‘» β€” it's there in the buffer, but it's not counted in buf_size. Plan your allocations accordingly, bestie.

Also lowkey important: buf may be null, and when it is, all you get back is the size. That's a feature, not a flop.

πŸ“ RETURNS πŸ“

  • GNUTLS_E_SHORT_MEMORY_BUFFER β€” if the provided buffer is not long enough, and in that case the buf_size will be updated with the required size. So it's not even being rude, it's telling you exactly how much more room you need. Helpful king. πŸ‘‘
  • GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE β€” if there are no data in the current index. Your indx went somewhere empty. Nothing there. Ghost town. πŸ’€
  • On success 0 is returned. Zero. The good zero. ✨

πŸ™ˆ REPORTING BUGS πŸ™ˆ

Found a bug? Don't suffer in silence, tell the whole group chat:


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.

(Translation: share it, remix it, print it on a tote bag, 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 visit

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

Like, if the local copy isn't there, the website literally always has your back. πŸ¦‹


Mwah πŸ’‹ this was the gnutls manual, page version 3.8.13, section 3 β€” gnutls_x509_crt_get_issuer_dn_by_oid(3). Go extract some issuer DNs, bestie, you're literally the main character of your own certificate chain. Periodt. πŸŽ€βœ¨

πŸ“¦ where this page comes from