nbd_set_tls_certificates(3)

πŸ’– nbd_set_tls_certificates β€” a libnbd(3) glow-up πŸ’–

okay so bestie, we're diving into nbd_set_tls_certificates from the libnbd manual, section 3. she's a little function with one job and she does it immaculately. let's get into it πŸŽ€

✨ NAME ✨

nbd_set_tls_certificates β€” literally just sets the path to the TLS certificates directory. that's it. that's her whole personality πŸ’…


🌸 SYNOPSIS 🌸

#include <libnbd.h>

int nbd_set_tls_certificates (
      struct nbd_handle *h, const char *dir
    );

look at that signature. clean. iconic. no notes 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so what does she do? she sets the path to the TLS certificates directory. simple as that, bestie.

if you don't set it and TLS gets used, there's a compiled-in default that kicks in:

  • for root, that's "/etc/pki/libnbd/"
  • for non-root, it's "$HOME/.pki/libnbd" and "$HOME/.config/pki/libnbd"

and if none of these directories can be found? then the system trusted CAs are used. fallback queen behavior honestly πŸ‘‘

ngl this is the important bit: this function may be called regardless of whether TLS is supported, but it will have no effect unless nbd_set_tls(3) is also used to request or require TLS. so like… she's ready whenever, but she's not doing anything until TLS actually shows up to the party πŸ’€

⭐ RETURN VALUE ⭐

if the call is successful, the function returns 0. slay. ✨


πŸ’€ ERRORS πŸ’€

on error, -1 is returned. not slay, but okay.

refer to "ERROR HANDLING" in libnbd(3) for how to get further details of the error.

also, heads up: the following parameters must not be NULL: "h", "dir". for more info see "Non-NULL parameters" in libnbd(3). don't be passing her nulls, she will not be okay with it πŸ™ˆ


🧚 HANDLE STATE 🧚

nbd_set_tls_certificates can be called when the handle is in the following state:

  • Handle created, before connecting β€” βœ… allowed
  • Connecting β€” ❌ error
  • Connecting & handshaking (opt_mode) β€” ❌ error
  • Connected to the server β€” ❌ error
  • Connection shut down β€” ❌ error
  • Handle dead β€” ❌ error

so basically: catch her early, before you connect. she's a before-the-party function, not a mid-party function. vibe check passed only in that first row πŸ’…


πŸŽ€ VERSION πŸŽ€

this function first appeared in libnbd 1.0. a whole legend from day one, fr fr.

if you need to test if this function is available at compile time, check if the following macro is defined:

#define LIBNBD_HAVE_NBD_SET_TLS_CERTIFICATES 1

🌈 SEE ALSO 🌈

go read them, they're all linked up, iykyk πŸ”₯


πŸ‘‘ AUTHORS πŸ‘‘

  • Eric Blake
  • Richard W.M. Jones

the icons who made this happen. we stan 🫢


Copyright Red Hat


πŸ“ LICENSE πŸ“

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

like, read the license, bestie. it's giving "legally required but also genuinely important" πŸ’–

and that's the whole page!! this lil beauty is from libnbd-1.25.8, dated 2026-10-13 β€” screenshot it, cite it, love it. mwah πŸ’‹βœ¨πŸŒΈ

πŸ“¦ where this page comes from