gnutls_x509_privkey_export2(3)

πŸ’– gnutls_x509_privkey_export2(3) β€” the gnutls girlies' guide πŸ’–

okay so bestie, this one lives in the gnutls manual, and it's literally the glow-up for getting your private key OUT of the library and into a cute little buffer. it's giving "export my whole vibe." let's go 🫢


✨ NAME ✨

gnutls_x509_privkey_export2 β€” an API function, no cap


🌸 SYNOPSIS 🌸

#include <gnutls/x509.h>

int gnutls_x509_privkey_export2(gnutls_x509_privkey_t key,
gnutls_x509_crt_fmt_t format, gnutls_datum_t * out);

πŸŽ€ ARGUMENTS πŸŽ€

  • gnutls_x509_privkey_t key β€” holds the key. she's the main character here, the whole reason we're gathered πŸ’…
  • gnutls_x509_crt_fmt_t format β€” the format of the output params, bestie. one of PEM or DER. pick one, that's the vibe check.
  • gnutls_datum_t * out β€” will contain a private key, either PEM or DER encoded. this is where she lands ✨

πŸ¦‹ DESCRIPTION πŸ¦‹

so this function will export the private key to a PKCS1 structure for RSA or RSA-PSS keys, and an integer sequence for DSA keys. other key types? they get exported in PKCS8 form instead. iykyk πŸ”₯

the output buffer is allocated using gnutls_malloc(). yes queen, she mallocs for you.

lowkey important: it is recommended to use gnutls_x509_privkey_export2_pkcs8() instead of this function, when a consistent output format is required. like, if you want everything to match, go talk to pkcs8 instead. not me being the chaotic one πŸ™ˆ

⭐ RETURNS ⭐

on success, GNUTLS_E_SUCCESS (0) is returned. otherwise you get a negative error value 😭 so like, check it, always.

since 3.1.3 β€” she's been iconic for a minute πŸ’œ


🌈 REPORTING BUGS 🌈

found a bug? don't be shy, tell the devs, they want the tea:


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. periodt. that's the whole legal vibe and she's generous fr fr.


πŸ’« 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 🧚 go forth and export responsibly. this was gnutls 3.8.13, page gnutls_x509_privkey_export2(3), signing off β€” stay slay, stay secure, and always free your buffers πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from