1.\" $OpenBSD: tls_client.3,v 1.2 2017/01/28 00:59:36 schwarze 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: January 28 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_free 25.Nd configure a TLS connection 26.Sh SYNOPSIS 27.In tls.h 28.Ft struct tls * 29.Fn tls_client void 30.Ft struct tls * 31.Fn tls_server void 32.Ft int 33.Fo tls_configure 34.Fa "struct tls *ctx" 35.Fa "struct tls_config *config" 36.Fc 37.Ft void 38.Fn tls_free "struct tls *ctx" 39.Sh DESCRIPTION 40A TLS connection is represented as a 41.Vt struct tls 42object called a 43.Dq context . 44A new context is created by either the 45.Fn tls_client 46or 47.Fn tls_server 48functions. 49.Fn tls_client 50is used in TLS client programs, 51.Fn tls_server 52in TLS server programs. 53.Pp 54The context can then be configured with the function 55.Fn tls_configure . 56The same 57.Vt tls_config 58object can be used to configure multiple contexts. 59.Pp 60After configuration, 61.Xr tls_connect 3 62can be called on objects created with 63.Fn tls_client , 64and 65.Xr tls_accept_socket 3 66on objects created with 67.Fn tls_server . 68.Pp 69After use, a TLS context should be closed with 70.Xr tls_close 3 , 71and then freed by calling 72.Fn tls_free . 73.Sh RETURN VALUES 74.Fn tls_client 75and 76.Fn tls_server 77return 78.Dv NULL 79on error or an out of memory condition. 80.Pp 81.Fn tls_configure 82returns 0 on success or -1 on error. 83.Sh SEE ALSO 84.Xr tls_accept_socket 3 , 85.Xr tls_config_new 3 , 86.Xr tls_connect 3 , 87.Xr tls_init 3 88.Sh HISTORY 89These functions appeared in 90.Ox 5.6 91and got their final names in 92.Ox 5.7 . 93.Sh AUTHORS 94.An Joel Sing Aq Mt jsing@openbsd.org 95