gnutls_server_name_set(3)

πŸ’– gnutls_server_name_set(3) β€” the gnutls manual, but make it make sense ✨

okay bestie, sit down, we're learning a gnutls API function and honestly? it's giving "small function, big responsibility." this one lives in the gnutls manual, section 3, and it's literally the thing that lets a client be like "hey server, i came here looking for this name" πŸŽ€


🌸 NAME 🌸

gnutls_server_name_set β€” which is an API function, no cap πŸ’…


✨ SYNOPSIS ✨

#include <gnutls/gnutls.h>

int gnutls_server_name_set(gnutls_session_t session,
gnutls_server_name_type_t type, const void * name, size_t name_length);

yes she's a four-argument girlie, we love a signature that eats 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • gnutls_session_t session β€” your session, babe. it's a gnutls_session_t type. that's the whole vibe.
  • gnutls_server_name_type_t type β€” this one specifies the indicator type. which indicator? the type of the name you're about to drop. iykyk.
  • const void * name β€” a string that contains the server name. the actual name. the main character of the operation πŸ‘‘
  • size_t name_length β€” holds the length of name, excluding the terminating null byte. do not count the null byte, i'm so serious, count only the real characters πŸ™ˆ

πŸ’œ DESCRIPTION πŸ’œ

so here's the tea. this function is for clients β€” specifically clients that want to inform the server, via a TLS extension mechanism, of the name they connected to. that's it. that's the whole job. 🌈

you should reach for this if you're a client connecting to servers that do virtual hosting. like, multiple sites on one box, and the server needs to know which one you meant. this is how you tell it. iconic behavior fr fr.

the value you pass in name depends on the type you pass in type. (yes, the naming is that direct, we respect the honesty.) specifically:

  • in the case of GNUTLS_NAME_DNS, what's expected is a UTF-8 null-terminated domain name string, without the trailing dot. so no example.com. β€” just example.com. leave the dot at home, she's not invited πŸ’€

and now the part where you need to pay attention, bestie:

IPv4 or IPv6 addresses are NOT permitted to be set by this function. not allowed. do not try it. it's not a "maybe don't," it's a "no."

also, fun little trick: if you call the function with a name of name_length zero, it will clear all server names that were set. so zero-length = the reset button 🧹✨


πŸ“ RETURNS πŸ“

on success, GNUTLS_E_SUCCESS (which is 0) is returned. otherwise? a negative error code is returned. so like, check your return values, please, i am begging 😭


πŸŽ€ REPORTING BUGS πŸŽ€

found a bug? spill to <bugs@gnutls.org>. πŸ›

home page: https://www.gnutls.org β€” go say hi, she's lovely.


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 forth, share the knowledge, 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/

and that's the page, bestie!! πŸ’– this was gnutls_server_name_set(3) from gnutls 3.8.13 β€” thanks for reading the whole thing, you ate that, periodt πŸ‘‘βœ¨

πŸ“¦ where this page comes from