gnutls_x509_privkey_import_pkcs8(3)

✨ gnutls_x509_privkey_import_pkcs8 ✨

okay bestie, welcome to the gnutls manual, page gnutls_x509_privkey_import_pkcs8(3) β€” yes it's a whole mouthful, yes it's an API function, and yes we're gonna get you fluent in it πŸ’…


🌸 NAME 🌸

gnutls_x509_privkey_import_pkcs8 β€” it's an API function, girlie. that's the whole vibe of the name. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnutls/x509.h>

int gnutls_x509_privkey_import_pkcs8(gnutls_x509_privkey_t key, const
gnutls_datum_t * data, gnutls_x509_crt_fmt_t format, const char *
password, unsigned int flags);

look at that signature. iconic. no notes. ✨


πŸ‘‘ ARGUMENTS πŸ‘‘

  • gnutls_x509_privkey_t key β€” this is where the parsed key is gonna live. it's the data to store the parsed key, basically the lil home you're giving your newly imported key 🏠
  • const gnutls_datum_t * data β€” the actual key itself, DER or PEM encoded. the main character of the whole operation fr fr πŸ”₯
  • gnutls_x509_crt_fmt_t format β€” pick your fighter: one of DER or PEM. that's it, those are the options πŸŽ€
  • const char * password β€” the password to decrypt the key, but only if it's encrypted. no password needed if it's out here raw and unencrypted 🫢
  • unsigned int flags β€” 0 if the key is encrypted, or GNUTLS_PKCS_PLAIN if it's not encrypted. that's the whole assignment bestie, don't overthink it πŸ’–

πŸ’œ DESCRIPTION πŸ’œ

so this function? it takes your DER or PEM encoded PKCS8 2.0 encrypted key and converts it into the native gnutls_x509_privkey_t format. glow-up complete ✨ the output lands in key. and good news: both RSA and DSA keys can be imported, and honestly flags can only be used to indicate an unencrypted key. that's its one job πŸŽ€

the password can be either ASCII or UTF-8 in the default PBES2 encryption schemas, or ASCII for the PKCS12 schemas. so like, mind your encoding, okay? 🧚

if the Certificate is PEM encoded it should have a header of "ENCRYPTED PRIVATE KEY", or "PRIVATE KEY". and listen β€” you only need to specify flags if the key is DER encoded, because in that case the encryption status cannot be auto-detected. DER is keeping secrets, lowkey rude of it πŸ’€

⚠️ if the GNUTLS_PKCS_PLAIN flag is specified and the supplied data are encrypted, then GNUTLS_E_DECRYPTION_FAILED gets returned. so don't lie to it about the encryption status, it WILL catch you πŸ™ˆ

🌈 RETURNS 🌈

on success, GNUTLS_E_SUCCESS (0) is returned β€” slay, we love a clean zero πŸ’– otherwise you get a negative error value. not the vibe, but at least it's honest about it.


πŸ’Œ REPORTING BUGS πŸ’Œ

found a bug? don't be shy, report 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 go forth and share, bestie 🫢


πŸ”₯ 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!! this was gnutls version 3.8.13, page gnutls_x509_privkey_import_pkcs8(3), brought to you by the gnutls manual itself. go import some keys, you absolute icon πŸ‘‘πŸ’…βœ¨

πŸ“¦ where this page comes from