1.\" $OpenBSD: tls_client.3,v 1.4 2017/08/12 03:41:48 jsing Exp $ 2.\" 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.Dd $Mdocdate: August 12 2017 $ 18.Dt TLS_CLIENT 3 19.Os 20.Sh NAME 21.Nm tls_client , 22.Nm tls_server , 23.Nm tls_configure , 24.Nm tls_reset , 25.Nm tls_free 26.Nd configure a TLS connection 27.Sh SYNOPSIS 28.In tls.h 29.Ft struct tls * 30.Fn tls_client void 31.Ft struct tls * 32.Fn tls_server void 33.Ft int 34.Fo tls_configure 35.Fa "struct tls *ctx" 36.Fa "struct tls_config *config" 37.Fc 38.Ft void 39.Fn tls_free "struct tls *ctx" 40.Ft void 41.Fn tls_reset "struct tls *ctx" 42.Sh DESCRIPTION 43A TLS connection is represented as a 44.Vt struct tls 45object called a 46.Dq context . 47A new context is created by either the 48.Fn tls_client 49or 50.Fn tls_server 51functions. 52.Fn tls_client 53is used in TLS client programs, 54.Fn tls_server 55in TLS server programs. 56.Pp 57The context can then be configured with the function 58.Fn tls_configure . 59The same 60.Vt tls_config 61object can be used to configure multiple contexts. 62.Pp 63After configuration, 64.Xr tls_connect 3 65can be called on objects created with 66.Fn tls_client , 67and 68.Xr tls_accept_socket 3 69on objects created with 70.Fn tls_server . 71.Pp 72After use, a TLS context should be closed with 73.Xr tls_close 3 , 74and then freed by calling 75.Fn tls_free . 76If 77.Fn tls_free 78is called with an argument of 79.Dv NULL , 80no action occurs. 81.Pp 82A TLS context can be reset by calling 83.Fn tls_reset , 84allowing for it to be reused. 85This is essentially equivalent to calling 86.Fn tls_free , 87followed by a call to the same function that was used to originally allocate 88the TLS context. 89.Sh RETURN VALUES 90.Fn tls_client 91and 92.Fn tls_server 93return 94.Dv NULL 95on error or an out of memory condition. 96.Pp 97.Fn tls_configure 98returns 0 on success or -1 on error. 99.Sh SEE ALSO 100.Xr tls_accept_socket 3 , 101.Xr tls_config_new 3 , 102.Xr tls_connect 3 , 103.Xr tls_init 3 104.Sh HISTORY 105These functions appeared in 106.Ox 5.6 107and got their final names in 108.Ox 5.7 . 109.Sh AUTHORS 110.An Joel Sing Aq Mt jsing@openbsd.org 111