NNG_HTTP_SERVER_SET_TLS(3http)

πŸ“¦ version 1.11, in alpine 3.24

πŸ’… NNG_HTTP_SERVER_SET_TLS(3http)

okay bestie, welcome to the nng_http_server_set_tls page β€” that's section 3http of the NNG Reference Manual, and yes it's exactly as niche as it sounds but we're gonna slay it together 🫢


✨ NAME ✨

nng_http_server_set_tls β€” sets the TLS configuration for your HTTP server. that's it, that's the whole vibe πŸ”₯


🌸 SYNOPSIS 🌸

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

int nng_http_server_set_tls(nng_http_server *s, nng_tls_config *cfg);

πŸŽ€ DESCRIPTION πŸŽ€

so nng_http_server_set_tls() takes the TLS configuration of server s and sets it to cfg. literally just handing your server its lil security outfit πŸ‘‘

this change overwrites any previous TLS configuration, no cap. so if you had one before? gone. replaced. moving on πŸ’…

⚠️ important, bestie, don't skip this one: this also invalidates any previously obtained values from nng_http_server_get_tls(). like, those pointers you grabbed earlier? they're not it anymore. don't be using stale stuff, i'm begging πŸ™ˆ

if the server is already running (i.e. it's been started with nng_http_server_start()) then this will fail with NNG_EBUSY. once the party's started you can't redecorate, fr fr 😭

πŸ’‘ tip: generally, cfg must have a configured private key, set with nng_tls_config_own_cert() or similar. no key, no entry, iykyk πŸ—οΈ

⭐ RETURN VALUES ⭐

this function returns 0 on success, and non-zero otherwise. classic. that's the whole return section, she's brief πŸ’–


πŸ¦‹ ERRORS πŸ¦‹

  • NNG_EBUSY β€” server instance is running. she's occupied, she's booked, try again never (until she stops) πŸ’€
  • NNG_ENOMEM β€” insufficient free memory exists. your RAM said "not today" πŸ˜”
  • NNG_ENOTSUP β€” either HTTP or TLS not supported. this build just doesn't have the range, and that's not on you 🌈

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the page, bestie πŸ“ that was the NNG Reference Manual, dated 2026-01-13 β€” go set some TLS, you're gonna do amazing, main character energy only πŸ§šπŸ’œ

πŸ“¦ where this page comes from