1 .\" $OpenBSD: tls_init.3,v 1.13 2018/07/09 19:47:20 tb 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: July 9 2018 $
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 is no longer necessary to call this function directly,
49 since it is invoked internally when needed.
50 It may be called more than once, and may be called concurrently.
52 Before a connection is created, a configuration must be created.
55 function allocates, initializes, and returns a new default configuration
56 object that can be used for future connections.
57 Several functions exist to change the options of the configuration; see
58 .Xr tls_config_set_protocols 3 ,
60 .Xr tls_config_ocsp_require_stapling 3 ,
62 .Xr tls_config_verify 3 .
66 function may be used to retrieve a string containing more information
67 about the most recent error relating to a configuration.
69 A TLS connection object is created by
76 A client connection is initiated after configuration by calling
78 A server can accept a new client connection by calling
79 .Xr tls_accept_socket 3
80 on an already established socket connection.
82 Two functions are provided for input and output,
86 Both automatically perform the
90 The properties of established TLS connections
91 can be inspected with the functions described in
92 .Xr tls_conn_version 3
94 .Xr tls_ocsp_process_response 3 .
96 After use, a TLS connection should be closed with
98 and then freed by calling
101 When no more contexts are to be configured,
102 the configuration object should be freed by calling
103 .Fn tls_config_free .
106 as soon as the final call to
116 returns 0 on success or -1 on error.
121 on error or an out of memory condition.
126 if no error occurred with
128 at all, or if memory allocation failed while trying to assemble the
129 string describing the most recent error related to
132 .Xr tls_accept_socket 3 ,
134 .Xr tls_config_ocsp_require_stapling 3 ,
135 .Xr tls_config_set_protocols 3 ,
136 .Xr tls_config_verify 3 ,
137 .Xr tls_conn_version 3 ,
139 .Xr tls_load_file 3 ,
140 .Xr tls_ocsp_process_response 3 ,
145 API first appeared in
147 as a response to the unnecessary challenges other APIs present in
148 order to use them safely.
150 All functions were renamed from
161 .An Joel Sing Aq Mt jsing@openbsd.org
162 .An Ted Unangst Aq Mt tedu@openbsd.org
164 Many others contributed to various parts of the library; see the
165 individual manual pages for more information.
169 returns an internal pointer.
170 It must not be freed by the application, or a double free error
172 The pointer will become invalid when the next error occurs with
174 Consequently, if the application may need the message at a later
175 time, it has to copy the string before calling the next
179 or a segmentation fault or read access to unintended data is the