gnutls_session_ext_register(3)
π gnutls_session_ext_register β bestie's guide to registering your very own TLS extension π
okay so this is a page from the gnutls manual (yes, the gnutls one, the TLS library, she's iconic) and today we're talking about gnutls_session_ext_register(3). it's giving "let me add my own extension to this session" energy. sit down, grab a strawberry π, we're doing this.
β¨ NAME β¨
gnutls_session_ext_register β API function. that's it, that's the name, short and slay.
πΈ SYNOPSIS πΈ
#include <gnutls/gnutls.h>
int gnutls_session_ext_register(gnutls_session_t session, const char *
name, int id, gnutls_ext_parse_type_t parse_point, gnutls_ext_recv_func
recv_func, gnutls_ext_send_func send_func, gnutls_ext_deinit_data_func
deinit_func, gnutls_ext_pack_func pack_func, gnutls_ext_unpack_func
unpack_func, unsigned flags);
look at her. ten parameters. main character energy fr fr π
π ARGUMENTS π
gnutls_session_t sessionβ the session where this extension is gonna live. it's the session, the one and only, no sharing bestie.const char * nameβ the name you're giving the extension you're registering. yes you get to name her, choose wisely π¦int idβ the numeric id of the extension. numbers only, this is the ID card.gnutls_ext_parse_type_t parse_pointβ the parse type of the extension (peepgnutls_ext_parse_type_tfor the deets). this is when in the handshake she gets parsed.gnutls_ext_recv_func recv_funcβ a function to receive the data. incoming π₯gnutls_ext_send_func send_funcβ a function to send the data. outgoing π€gnutls_ext_deinit_data_func deinit_funcβ a function that deinitializes any private data. cleanup era, we love to see it π§Ήgnutls_ext_pack_func pack_funcβ a function which serializes the extension's private data (used on session packing for resumption). she packs it up all cute for later πΌgnutls_ext_unpack_func unpack_funcβ a function which will deserialize the extension's private data. unpacking, obviously πunsigned flagsβ must be zero, or flags fromgnutls_ext_flags_t. zero or the flag list, no in-between.
π DESCRIPTION π
so like. this function registers a new extension type. periodt. but listen β the extension will be only usable within the registered session. it's not going global, it's a session-exclusive little thing, iykyk.
if the extension type is already registered, then GNUTLS_E_ALREADY_REGISTERED gets returned. rude, but fair. unless you pass the flag GNUTLS_EXT_FLAG_OVERRIDE_INTERNAL β then you're overriding, and that's on period.
that override flag, when specified, can be used to override certain extensions introduced after 3.6.0. it's expected to be used by applications that handle custom extensions which aren't currently supported in GnuTLS β but direct support for them may be added in the future. so like, heads up, your little workaround might get adopted by the library one day π.
each registered extension can store temporary data into the gnutls_session_t structure using gnutls_ext_set_data(), and they can be retrieved using gnutls_ext_get_data(). store and retrieve, a whole little ecosystem π.
the validity of the extension you registered can be given by the appropriate flags of gnutls_ext_flags_t. and if no validity is given, then the registered extension will be valid for client and TLS1.2 server hello (or encrypted extensions for TLS1.3). so if you say nothing, that's the default vibe check result β¨.
β RETURNS β
GNUTLS_E_SUCCESS on success π β otherwise a negative error code, aka not the vibe π.
π¦ SINCE π¦
3.5.5. she's been around, she's a legacy icon π
π REPORTING BUGS π
found a bug? don't be shy, report bugs to <bugs@gnutls.org>. home page: 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 yes, you can share this, 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/
okay that's the whole page bestie, you ate that π«Ά this was gnutls_session_ext_register(3) from the gnutls manual, version 3.8.13, brought to you with so much love. mwah π
β¨π
π¦ 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