GNUTLS_X509_CRT_GET_SUBJECT_ALT_NAME(3)

πŸ’– gnutls_x509_crt_get_subject_alt_name(3) πŸ’–

okay bestie, so this one lives in the gnutls manual β€” yeah, the whole gnutls documentation set, and this page is literally titled gnutls_x509_crt_get_subject_alt_name. it's an API function, which is just a fancy way of saying "a function you can call from your C code" 🫢


✨ NAME ✨

gnutls_x509_crt_get_subject_alt_name β€” API function. that's it, that's the name, no notes πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

like, here's how you summon it:

#include <gnutls/x509.h>

int gnutls_x509_crt_get_subject_alt_name(gnutls_x509_crt_t cert,
unsigned int seq, void * san, size_t * san_size, unsigned int *
critical);

the include goes at the top, the function goes wherever you need it, slay 🌸


πŸ¦‹ ARGUMENTS πŸ¦‹

  • gnutls_x509_crt_t cert β€” this should contain a gnutls_x509_crt_t type. it's the certificate you're poking at, basically the main character of this whole operation πŸ‘‘
  • unsigned int seq β€” specifies the sequence number of the alt name. 0 for the first one, 1 for the second etc. so like, indexing. zero-indexed. iconic behaviour fr fr ✨
  • void * san β€” is the place where the alternative name will be copied to. so you bring the buffer, it fills the buffer πŸ’–
  • size_t * san_size β€” holds the size of san. you tell it how much room you've got, it tells you how much it actually needed 🌈
  • unsigned int * critical β€” will be non-zero if the extension is marked as critical. may be null, so it's optional, no pressure, lowkey chill about it πŸ™ˆ

πŸ’œ DESCRIPTION πŸ’œ

so what does it actually do. this function retrieves the Alternative Name (2.5.29.17), contained in the given certificate in the X509v3 Certificate Extensions. the SAN. the moment. the legend ⭐

now here's the tea: when the SAN type is otherName, it will extract the data in the otherName's value field, and GNUTLS_SAN_OTHERNAME is returned. you may use gnutls_x509_crt_get_subject_alt_othername_oid() to get the corresponding OID and the "virtual" SAN types (e.g., GNUTLS_SAN_OTHERNAME_XMPP). virtual types?? in my SAN?? it's giving layers πŸ’…

if an otherName OID is known, the data will be decoded. otherwise the returned data will be DER encoded, and you will have to decode it yourself. so like, you're on your own for that one, bestie, no cap 😭 currently, only the RFC 3920 id-on-xmppAddr SAN is recognized. just the one. the chosen one. the only child πŸŽ€


πŸ”₯ RETURNS πŸ”₯

it returns the alternative subject name type on success, one of the enumerated gnutls_x509_subject_alt_name_t. periodt ✨

but also:

  • it will return GNUTLS_E_SHORT_MEMORY_BUFFER if san_size is not large enough to hold the value. in that case san_size will be updated with the required size. so like, it tells you how much bigger to go. helpful king πŸ’–
  • if the certificate does not have an Alternative name with the specified sequence number then GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE is returned. not there. doesn't exist. we looked. nothing. πŸ’€

😭 REPORTING BUGS 😭

found a bug? don't suffer in silence, tell the people:


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 you can copy it, 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 it's not on your machine, it's on the internet. it's fine. we got you 🌈


and that's the whole page, bestie πŸ’œ this one came from the gnutls manual, page gnutls_x509_crt_get_subject_alt_name(3), version 3.8.13 β€” go read your SANs, you're gonna do amazing, i'm obsessed πŸ«ΆπŸ’–βœ¨

πŸ“¦ where this page comes from