gnutls_store_pubkey(3)

πŸ’– gnutls_store_pubkey β€” the manual page, but make it cute πŸ’–

okay bestie, welcome to the gnutls manual, section 3. today's main character is gnutls_store_pubkey, and she's literally the API function that files your peer's public key away so you don't have to re-verify it every single time. no cap. πŸŽ€


✨ NAME ✨

gnutls_store_pubkey β€” API function πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnutls/gnutls.h>

int gnutls_store_pubkey(const char * db_name, gnutls_tdb_t tdb, const
char * host, const char * service, gnutls_certificate_type_t cert_type,
const gnutls_datum_t * cert, time_t expiration, unsigned int flags);

like look at her. eight arguments. she's that girl. πŸ‘‘


🌸 ARGUMENTS 🌸

  • const char * db_name β€” a file that says where the stored keys live. pass NULL if you want the default one, bestie.
  • gnutls_tdb_t tdb β€” a storage structure, or NULL to just use the default. 🫢
  • const char * host β€” the peer's name. yes, their name. πŸ’œ
  • const char * service β€” non-NULL if this key is specific to a service (think http). otherwise leave it be.
  • gnutls_certificate_type_t cert_type β€” the type of the certificate.
  • const gnutls_datum_t * cert β€” the actual data of the certificate.
  • time_t expiration β€” when this key expires. use 0 to disable expiration entirely (immortal key era ✨).
  • unsigned int flags β€” should be 0. that's it. that's the whole vibe check.

πŸ’… DESCRIPTION πŸ’…

so this function stores a raw public-key β€” or a public-key that came in via a raw (DER-encoded) certificate β€” into the list of stored public keys. the key stays considered valid until the expiration time you handed over. periodt. πŸ”₯

the tdb variable, if it's non-null, specifies a custom backend for storing entries. if it's NULL? then the default file backend gets used, no questions asked. πŸ’«

unless you provide an alternative tdb, the storage format is a textual format β€” one line per host, fields separated by '|'. and the contents of those fields, in order, are:

  1. a format-identifier, which is set to 'g0'
  2. the hostname that the rest of the data applies to
  3. the numeric port or host name
  4. the expiration time in seconds since the epoch (0 for no expiration)
  5. a base64 encoding of the raw (DER) public key information (SPKI) of the peer

as of GnuTLS 3.6.6, this function also accepts raw public keys. glow-up behavior fr fr. 🌈


⭐ RETURNS ⭐

on success, GNUTLS_E_SUCCESS (0) is returned. otherwise you get a negative error value. 😭 she's not mad, she's just disappointed.


πŸŽ€ SINCE πŸŽ€

3.0.13 β€” vintage, but in a chic way. πŸ“


πŸ™ˆ REPORTING BUGS πŸ™ˆ

found a bug? spill it to bugs@gnutls.org.

home page: https://www.gnutls.org


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, 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 whole page, bestie!! πŸ’– this was gnutls 3.8.13, manual section 3, and yes we are absolutely obsessed with her. mwah. πŸ’…βœ¨πŸ§š

πŸ“¦ where this page comes from