NNG_TLS_CONFIG_OWN_CERT(3tls)

πŸ“¦
version 1.12.0 Β· 4 versions
, in ubuntu stonking

πŸ’– nng_tls_config_own_cert πŸ’–

okay bestie, this is a page from the NNG Reference Manual, and it's about giving your TLS setup its very own ✨identity✨ β€” like, a certificate that says this is me and a secret key that proves it. let's get into it 🫢


🌸 NAME 🌸

nng_tls_config_own_cert β€” configure own certificate and key πŸ’…


✨ SYNOPSIS ✨

#include <nng/nng.h>
#include <nng/supplemental/tls/tls.h>

int nng_tls_config_own_cert(nng_tls_config *cfg, const char *cert,
    const char *key, const char *pass);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, the nng_tls_config_own_cert() function is the one that sets up a certificate cert that identifies the local side of a TLS connection being used with cfg. and obviously it needs the matching private or secret key key, because a cert with no key is giving nothing, honestly.

the certificate can be a chain β€” leaf signer first, root at the very end, in that order, no cap. and here's the cute part: the self-signed certificate at the end can be omitted πŸ’« (the client should already have it, and literally will have to have it in order to validate this certificate anyway).

the key can be encrypted with a password, and if it is, you drop that password in pass. if the key is not encrypted, supply NULL for pass. that's it, that's the whole vibe check.

on servers, you can call this function multiple times for the same configuration β€” which is lowkey so useful for specifying different parameters to be used for different cryptographic algorithms. slay 🌈

now, important: the certificate in cert and the key in key must be NUL (\0) terminated C strings containing PEM-formatted material (per [RFC 7468](https://tools.ietf.org/html/rfc7468)). no half-finished strings, bestie, we need the terminator.

⚠️ rude reminder: those strings gotta be NUL (\0) terminated and PEM formatted. if they're not, this is not going to go how you want it to go. 😭

πŸŽ€ RETURN VALUES πŸŽ€

this function returns 0 when everything is iconic and working, and non-zero otherwise. that's the rule. periodt.


πŸ’€ ERRORS πŸ’€

  • NNG_ENOMEM β€” insufficient memory is available. the machine said "no thoughts, head empty" πŸ™ˆ
  • NNG_EBUSY β€” the configuration cfg is already in use, and cannot be modified. it's busy, it's booked, it's not taking changes rn πŸ’…
  • NNG_EINVAL β€” an invalid cert or key was supplied. something in there was not giving what it needed to give πŸ“

πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, bestie πŸ’œ this was NNG_TLS_CONFIG_OWN_CERT(3tls), from the NNG Reference Manual, dated 2026-06-30. go forth and certify yourself, you main character πŸ‘‘βœ¨πŸ§š

πŸ“¦ where this page comes from