gnutls_x509_privkey_export(3)
π gnutls_x509_privkey_export β bestie, let's get that key OUT of the vault π
okay so this is a page from the gnutls manual (yes, that gnutls, the TLS library that's been holding it down since forever) and today we're talking about gnutls_x509_privkey_export. it's an API function. it does exactly what it sounds like. we're exporting a private key. slay. π
β¨ SYNOPSIS β¨
#include <gnutls/x509.h>
int gnutls_x509_privkey_export(gnutls_x509_privkey_t key,
gnutls_x509_crt_fmt_t format, void * output_data, size_t *
output_data_size);
π ARGUMENTS π
gnutls_x509_privkey_t keyβ this is the key itself, the main character, the whole point of the operation π it's holding your key.gnutls_x509_crt_fmt_t formatβ the format of the output params. it's one ofPEMorDER. pick one, no both.void * output_dataβ this is where the private key lands, PEM or DER encoded, all cozy in there.size_t * output_data_sizeβ holds the size ofoutput_datawhen you hand it over (and will be replaced by the actual size of parameters once it's done, so it's giving before-and-after energy).
πΈ DESCRIPTION πΈ
so here's the tea. this function will export the private key to a PKCS1 structure for RSA or RSA-PSS keys, and to an integer sequence for DSA keys. other key types? they get exported in PKCS8 form. no cap, that's just how it goes.
if the structure is PEM encoded, it will have a header of "BEGIN RSA PRIVATE KEY". periodt. π
β οΈ okay bestie listen β it is recommended to use gnutls_x509_privkey_export_pkcs8() instead of this function, when a consistent output format is required. like if you need everything to match, that's the move. this one? it's giving variety. know what you're getting into. π
π« RETURNS π«
on success, GNUTLS_E_SUCCESS (0) is returned. otherwise you get a negative error value and we're sad. π
π¦ REPORTING BUGS π¦
found a bug? don't suffer in silence, tell the people:
- 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.
π 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 π«Ά go forth, export responsibly, and remember: gnutls_x509_privkey_export_pkcs8() if you want consistency. this page came to you from gnutls version 3.8.13, so if your version says something different, that's between you and your distro. 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