1nbd_opt_starttls(3) LIBNBD nbd_opt_starttls(3)
2
3
4
6 nbd_opt_starttls - request the server to initiate TLS
7
9 #include <libnbd.h>
10
11 int nbd_opt_starttls (
12 struct nbd_handle *h
13 );
14
16 Request that the server initiate a secure TLS connection, by sending
17 "NBD_OPT_STARTTLS". This can only be used if nbd_set_opt_mode(3)
18 enabled option mode; furthermore, if you use nbd_set_tls(3) to request
19 anything other than the default of "LIBNBD_TLS_DISABLE", then libnbd
20 will have already attempted a TLS connection prior to allowing you
21 control over option negotiation. This command is disabled if
22 nbd_supports_tls(3) reports false.
23
24 This function is mainly useful for integration testing of corner cases
25 in server handling; in particular, misuse of this function when coupled
26 with a server that is not careful about resetting stateful commands
27 such as nbd_opt_structured_reply(3) could result in a security hole
28 (see CVE-2021-3716 against nbdkit, for example). Thus, when security
29 is a concern, you should instead prefer to use nbd_set_tls(3) with
30 "LIBNBD_TLS_REQUIRE" and let libnbd negotiate TLS automatically.
31
32 This function returns true if the server replies with success, false if
33 the server replies with an error, and fails only if the server does not
34 reply (such as for a loss of connection, which can include when the
35 server rejects credentials supplied during the TLS handshake). Note
36 that the NBD protocol documents that requesting TLS after it is already
37 enabled is a client error; most servers will gracefully fail a second
38 request, but that does not downgrade a TLS session that has already
39 been established, as reported by nbd_get_tls_negotiated(3).
40
42 This call returns a boolean value.
43
45 On error -1 is returned.
46
47 Refer to "ERROR HANDLING" in libnbd(3) for how to get further details
48 of the error.
49
50 The following parameters must not be NULL: "h". For more information
51 see "Non-NULL parameters" in libnbd(3).
52
54 The handle must be negotiating, otherwise this call will return an
55 error.
56
58 This function first appeared in libnbd 1.16.
59
60 If you need to test if this function is available at compile time check
61 if the following macro is defined:
62
63 #define LIBNBD_HAVE_NBD_OPT_STARTTLS 1
64
66 nbd_aio_opt_starttls(3), nbd_create(3), nbd_get_tls_negotiated(3),
67 nbd_opt_structured_reply(3), nbd_set_opt_mode(3), nbd_set_tls(3),
68 nbd_supports_tls(3), libnbd(3).
69
71 Eric Blake
72
73 Richard W.M. Jones
74
76 Copyright Red Hat
77
79 This library is free software; you can redistribute it and/or modify it
80 under the terms of the GNU Lesser General Public License as published
81 by the Free Software Foundation; either version 2 of the License, or
82 (at your option) any later version.
83
84 This library is distributed in the hope that it will be useful, but
85 WITHOUT ANY WARRANTY; without even the implied warranty of
86 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
87 Lesser General Public License for more details.
88
89 You should have received a copy of the GNU Lesser General Public
90 License along with this library; if not, write to the Free Software
91 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
92 02110-1301 USA
93
94
95
96libnbd-1.18.1 2023-10-31 nbd_opt_starttls(3)