1 .\" $OpenBSD: tls_init.3,v 1.7 2017/05/06 21:18:48 jsing Exp $
3 .\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4 .\" Copyright (c) 2016 Joel Sing <jsing@openbsd.org>
5 .\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
7 .\" Permission to use, copy, modify, and distribute this software for any
8 .\" purpose with or without fee is hereby granted, provided that the above
9 .\" copyright notice and this permission notice appear in all copies.
11 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 .Dd $Mdocdate: May 6 2017 $
27 .Nd initialize TLS client and server API
32 .Ft struct tls_config *
33 .Fn tls_config_new void
35 .Fn tls_config_free "struct tls_config *config"
37 .Fn tls_config_error "struct tls_config *config"
41 family of functions establishes a secure communications channel
42 using the TLS socket protocol.
43 Both clients and servers are supported.
47 function initializes global data structures.
48 It should be called once before any other functions.
49 It may be called more than once, but not concurrently.
51 Before a connection is created, a configuration must be created.
54 function allocates, initializes, and returns a new default configuration
55 object that can be used for future connections.
56 Several functions exist to change the options of the configuration; see
57 .Xr tls_config_set_protocols 3 ,
59 .Xr tls_config_ocsp_require_stapling 3 ,
61 .Xr tls_config_verify 3 .
65 function may be used to retrieve a string containing more information
66 about the most recent error relating to a configuration.
68 A TLS connection object is created by
75 A client connection is initiated after configuration by calling
77 A server can accept a new client connection by calling
78 .Xr tls_accept_socket 3
79 on an already established socket connection.
81 Two functions are provided for input and output,
85 Both automatically perform the
89 The properties of established TLS connections
90 can be inspected with the functions described in
91 .Xr tls_conn_version 3
93 .Xr tls_ocsp_process_response 3 .
95 After use, a TLS connection should be closed with
97 and then freed by calling
100 When no more contexts are to be configured,
101 the configuration object should be freed by calling
102 .Fn tls_config_free .
105 as soon as the final call to
115 returns 0 on success or -1 on error.
120 on error or an out of memory condition.
125 if no error occurred with
127 at all, or if memory allocation failed while trying to assemble the
128 string describing the most recent error related to
131 .Xr tls_accept_socket 3 ,
133 .Xr tls_config_ocsp_require_stapling 3 ,
134 .Xr tls_config_set_protocols 3 ,
135 .Xr tls_config_verify 3 ,
136 .Xr tls_conn_version 3 ,
138 .Xr tls_load_file 3 ,
139 .Xr tls_ocsp_process_response 3 ,
144 API first appeared in
146 as a response to the unnecessary challenges other APIs present in
147 order to use them safely.
149 All functions were renamed from
160 .An Joel Sing Aq Mt jsing@openbsd.org
161 .An Ted Unangst Aq Mt tedu@openbsd.org
163 Many others contributed to various parts of the library; see the
164 individual manual pages for more information.
168 returns an internal pointer.
169 It must not be freed by the application, or a double free error
171 The pointer will become invalid when the next error occurs with
173 Consequently, if the application may need the message at a later
174 time, it has to copy the string before calling the next
178 or a segmentation fault or read access to unintended data is the