GNUTLS_CERTIFICATE_SET_RAWPK_KEY_MEM(3)
β¨ NAME β¨
gnutls_certificate_set_rawpk_key_mem β bestie, it's an API function π (from the gnutls manual, page gnutls_certific...t_rawpk_key_mem(3))
πΈ SYNOPSIS πΈ
#include <gnutls/gnutls.h>
int
gnutls_certificate_set_rawpk_key_mem(gnutls_certificate_credentials_t
cred, const gnutls_datum_t * spki, const gnutls_datum_t * pkey,
gnutls_x509_crt_fmt_t format, const char * pass, unsigned int key_usage,
const char ** names, unsigned int names_length, unsigned int flags);
π ARGUMENTS π
gnutls_certificate_credentials_t credβ this is literally agnutls_certificate_credentials_ttype, that's the whole vibe.const gnutls_datum_t * spkiβ holds a raw public key inPKIX.SubjectPublicKeyInfoformat πconst gnutls_datum_t * pkeyβ holds a raw private key πgnutls_x509_crt_fmt_t formatβ the encoding of the keys.DERorPEM, pick your fighter.const char * passβ an optional password to unlock the private keypkey(optional!! so if it's not locked you can just not).unsigned int key_usageβ an ORed sequence ofGNUTLS_KEY_*flags.const char ** namesβ an array of DNS names belonging to the public-key (NULLif there are none).unsigned int names_lengthβ holds the length of thenameslist.unsigned int flagsβ an ORed sequence ofgnutls_pkcs_encrypt_flags_t. These apply to the private keypkey.
π DESCRIPTION π
So basically, this function sets a public/private keypair inside the gnutls_certificate_credentials_t type so it can be used for authentication and/or encryption. Iconic, honestly.
spki and privkey should match β otherwise the set signatures cannot be validated π and if they don't match, this function returns GNUTLS_E_CERTIFICATE_KEY_MISMATCH. No cap.
Also: call this function once for the client, because rn there is currently no mechanism to determine which raw public-key to select for the peer when there are multiple present. (Multiple raw public keys for the server can be distinguished by setting the names, so server girlies have options. πβοΈ)
Note here that spki is a raw public-key as defined in RFC7250. That means there is no surrounding certificate holding the public key, and therefore no direct mechanism to prove the authenticity of this key. The keypair can be used during a TLS handshake, but its authenticity should be established via a different mechanism (e.g. TOFU or known fingerprint). So like⦠vibe check it yourself, bestie.
The supported formats are basic unencrypted key, PKCS8, PKCS12, and the openssl format β and they will be autodetected β¨ (she just knows).
If the raw public-key and the private key are given in PEM encoding, then the strings that hold their values must be null terminated. Periodt.
Key usage (as defined by the X.509 extension (2.5.29.15)) can be explicitly set, because there is no certificate structure around the key to define this value. For more info see gnutls_x509_crt_get_key_usage().
Okay and here's the returns tea: 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 in other functions to refer to the added key-pair. Slay, a little handle for your little keypair π«Ά
β RETURNS β
On success, GNUTLS_E_SUCCESS (0) is returned. In case the key pair does not match, GNUTLS_E_CERTIFICATE_KEY_MISMATCH is returned. In other erroneous cases, a different negative error code is returned. (Negative = it's giving sad. π)
π¦ SINCE π¦
3.6.6 β she's been around a minute, an OG.
π REPORTING BUGS π
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. (Yes bestie, you can share it, 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/
Okay that's the whole page, mwah π β this was gnutls version 3.8.13, page gnutls_certific...t_rawpk_key_mem(3), and yes the man page name is literally truncated like that in real life, we don't make the rules. Go forth and set those raw public keys, bestie π§β¨
π¦ 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