NNG_TLS_CONFIG_CERT_KEY_FILE(3tls)
π NAME π
nng_tls_config_cert_key_file β bestie, this loads your own cert AND your private key straight out of a file π
β¨ SYNOPSIS β¨
#include <nng/nng.h>
#include <nng/supplemental/tls/tls.h>
int nng_tls_config_cert_key_file(nng_tls_config *cfg, const char *path,
const char *pass);
πΈ DESCRIPTION πΈ
Okay so nng_tls_config_cert_key_file() is the glow-up function: it loads a certificate (or a whole certificate chain, she's flexible π
) plus a private key from the file you point at with path.
That file has to be both things at once β the PEM encoded certificate and its associated private key, all cozy in the same file (https://tools.ietf.org/html/rfc7468 if you wanna read the PEM lore, iykyk). These are what get used whenever TLS sessions are established using cfg. The file may also carry extra certificates that lead up the validation chain, and the leaf certificate has to come first π. And no, you do not need to include the self-signed root β the peer already has to have that in order to do its own validation, so it's giving redundant. Skip it, queen.
Now the private key β she might be encrypted with a password, and if she is, you hand that password over in pass. If the key isn't encrypted, you pass NULL for pass. That's it, that's the whole vibe check.
On servers π₯οΈ, you can literally call this function multiple times for the same configuration. Not a bug, it's a feature β it's useful for specifying different parameters to be used for different cryptographic algorithms. Slay.
π« RETURN VALUES π«
This function returns 0 on success, and non-zero otherwise. That's the whole story.
π ERRORS π
NNG_ENOMEMβ insufficient memory is available. She's out of RAM, tragic.NNG_EBUSYβ the configurationcfgis already in use, and cannot be modified. Locked in, sorry bestie.NNG_EINVALβ the contents ofpathare invalid.NNG_ENOENTβ the file named bypathdoes not exist. Nowhere to be found, ghosted fr fr πNNG_EPERMβ the file named bypathcannot be opened. Permission said no π
π¦ SEE ALSO π¦
a lil sign-off from your fav: this was the NNG_TLS_CO...T_KEY_FILE(3tls) page from the NNG Reference Manual, dated 2026-06-30. go set up some TLS and be iconic about it β¨π«Ά
π¦ where this page comes from
- ubuntu stonking: libnng-dev 1.12.0-1 Β· MIT OR Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms