gnutls_certifi..._rawpk_key_file(3)
π gnutls_certificate_set_rawpk_key_file β the manual page, but make it make sense π
okay bestie, sit down, hydrate, because we're reading a gnutls man page together and honestly? it's giving "raw public keys have no certificate to hide behind" and we're gonna slay it. this is page gnutls_certificate_set_rawpk_key_file(3) from the gnutls manual, and it is lowkey iconic. π
β¨ NAME β¨
gnutls_certificate_set_rawpk_key_file β API function. that's it, that's the name, she's a function and she's an API one, periodt. π
πΈ SYNOPSIS πΈ
here's the summoning circle, copy it exactly, no typos, i'm watching:
#include <gnutls/gnutls.h>
int
gnutls_certificate_set_rawpk_key_file(gnutls_certificate_credentials_t
cred, const char * rawpkfile, const char * privkeyfile,
gnutls_x509_crt_fmt_t format, const char * pass, unsigned int key_usage,
const char ** names, unsigned int names_length, unsigned int
privkey_flags, unsigned int pkcs11_flags);
π¦ ARGUMENTS π¦
the whole cast, in order, no one gets cut from the group chat:
gnutls_certificate_credentials_t credβ this is agnutls_certificate_credentials_ttype. it's the lil container everything gets stuffed into.const char * rawpkfileβ holds a raw public key, inPKIX.SubjectPublicKeyInfoformat. raw. unhinged. no certificate wrapper. we love her.const char * privkeyfileβ a file path pointing at a private key. yes, a path, not the key itself.gnutls_x509_crt_fmt_t formatβ the encoding of the keys.DERorPEM, pick one, choose your fighter.const char * passβ an optional password to unlock the private keyprivkeyfile. optional!! don't come for me if you leave it out.unsigned int key_usageβ an ORed sequence ofGNUTLS_KEY_*flags. ORed, bestie, bitwise, you know the vibe.const char ** namesβ an array of DNS names belonging to the public-key. it'sNULLif there are none.unsigned int names_lengthβ holds the length of thenameslist. gotta say how many, she doesn't count for you.unsigned int privkey_flagsβ an ORed sequence ofgnutls_pkcs_encrypt_flags_t. these apply to the private keypkey.unsigned int pkcs11_flagsβ one ofgnutls_pkcs11_obj_flags. these apply to URLs.
π DESCRIPTION π
so what does this function do? she sets a public/private keypair, read from a file, into the gnutls_certificate_credentials_t type, so it can be used for authentication and/or encryption. main character energy tbh.
β οΈspkiandprivkeyshould match. if they don't, set signatures cannot be validated, and this function returnsGNUTLS_E_CERTIFICATE_KEY_MISMATCH. no cap. mismatched keys are a crime scene.
this function should be called once for the client, because there is currently no mechanism to determine which raw public-key to select for the peer when there are multiple present. so like. one and done, babe. multiple raw public keys for the server can be distinguished by setting the names. π
note here that spki is a raw public-key as defined in RFC7250. meaning: there is no surrounding certificate that holds the public key, and there is 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). that's a big deal, so let's say it louder for the people in the back β no cert around it, no built-in proof. π«Ά
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. do not forget the null terminator, i am begging you. π
key usage (as defined by X.509 extension (2.5.29.15)) can be explicitly set, because there is no certificate structure around the key to define this value. see for more info gnutls_x509_crt_get_key_usage().
note that this function by default returns zero on success and a negative value on error. 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. a lil receipt, if you will. π§Ύ
π RETURNS π
- on success,
GNUTLS_E_SUCCESS(0) is returned. slay. - in case the key pair does not match,
GNUTLS_E_CERTIFICATE_KEY_MISMATCHis returned. π - in other erroneous cases, a different negative error code is returned.
β SINCE β
3.6.6 β she's been around, she's not new here, respect the elders.
π REPORTING BUGS π
found a bug? do not suffer in silence, bestie:
- 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. so like, go off, but 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/
and that's the whole page, bestie!! go forth and set your raw public key files responsibly π¦πβ¨ β from the gnutls 3.8.13 manual, with love, 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