gnutls_certifi...et_x509_key_mem(3)
π NAME π
gnutls_certificate_set_x509_key_mem β bestie, it's the API function that pairs your cert with your private key, straight from memory β¨
This one lives in the gnutls manual, and honestly? She's a baddie.
πΈ SYNOPSIS πΈ
#include <gnutls/gnutls.h>
int gnutls_certificate_set_x509_key_mem(gnutls_certificate_credentials_t
res, const gnutls_datum_t * cert, const gnutls_datum_t * key,
gnutls_x509_crt_fmt_t type);
π ARGUMENTS π
gnutls_certificate_credentials_t resβ okay so this is agnutls_certificate_credentials_ttype. That's the whole vibe. She's the credentials girlie you're loading stuff into πconst gnutls_datum_t * certβ this holds a certificate list (path) for the specified private key. Not just one cert, bestie, a whole list, iykyk π¦const gnutls_datum_t * keyβ this is the private key, orNULL. Yes,NULLis allowed, stay with me π₯gnutls_x509_crt_fmt_t typeβ this isPEMorDER. That's it. Pick your fighter π
β¨ DESCRIPTION β¨
So what does this do? It sets a certificate/private key pair inside the gnutls_certificate_credentials_t type. Iconic behaviour, honestly.
And here's the cute part: this function may be called more than once, in case multiple keys/certificates exist for the server. She's not a one-and-done girlie, she's flexible π«Ά
Heads up though β note that thekeyUsage(2.5.29.15) PKIX extension in X.509 certificates is supported. Which means certificates intended for signing cannot be used for ciphersuites that require encryption. So don't try it. The extension said no and she meant it π
Another thing, and this one matters: if the certificate and the private key are given in PEM encoding, then the strings that hold their values must be null terminated. Null terminate them. Please. For me. π
The key may be NULL if you are using a sign callback β see gnutls_sign_callback_set() for that whole situation π
And now the plot twist: this function by default returns zero on success and a negative value on error. But β since 3.5.6, when the flag GNUTLS_CERTIFICATE_API_V2 is set using gnutls_certificate_set_flags(), it returns an index (greater or equal to zero). That index can be used by other functions to refer to the added key-pair. Main character behaviour tbh π
π RETURNS π
On success this function returns zero, and otherwise a negative value on error (see above for modifying that behavior). Lowkey simple, highkey important π
π REPORTING BUGS π
Found a bug? Tell the girlies.
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. Slay, and also legally binding π
π 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_certifi...et_x509_key_mem(3) from the gnutls manual, version 3.8.13 β go forth and null-terminate your PEM strings, no cap π
β¨
π¦ 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