1TLS_CONNECT(3)           BSD Library Functions Manual           TLS_CONNECT(3)
2

NAME

4     tls_connect, tls_connect_fds, tls_connect_servername, tls_connect_socket,
5     tls_connect_cbs — instruct a TLS client to establish a connection
6

SYNOPSIS

8     #include <tls.h>
9
10     int
11     tls_connect(struct tls *ctx, const char *host, const char *port);
12
13     int
14     tls_connect_fds(struct tls *ctx, int fd_read, int fd_write,
15         const char *servername);
16
17     int
18     tls_connect_servername(struct tls *ctx, const char *host,
19         const char *port, const char *servername);
20
21     int
22     tls_connect_socket(struct tls *ctx, int s, const char *servername);
23
24     int
25     tls_connect_cbs(struct tls *ctx,
26         ssize_t (*tls_read_cb)(struct tls *ctx, void *buf, size_t buflen, void *cb_arg),
27         ssize_t (*tls_write_cb)(struct tls *ctx, const void *buf, size_t buflen, void *cb_arg),
28         void *cb_arg, const char *servername);
29

DESCRIPTION

31     After creating a TLS client context with tls_client(3) and configuring it
32     with tls_configure(3), a client connection is initiated by calling
33     tls_connect().  This function will create a new socket, connect to the
34     specified host and port, and then establish a secure connection.  The
35     port may be numeric or a service name.  If it is NULL, then a host of the
36     format "hostname:port" is permitted.  The name to use for verification is
37     inferred from the host value.
38
39     The tls_connect_servername() function has the same behaviour, however the
40     name to use for verification is explicitly provided, for the case where
41     the TLS server name differs from the DNS name.
42
43     An already existing socket can be upgraded to a secure connection by
44     calling tls_connect_socket().
45
46     Alternatively, a secure connection can be established over a pair of
47     existing file descriptors by calling tls_connect_fds().
48
49     Calling tls_connect_cbs() allows read and write callback functions to
50     handle data transfers.  The specified cb_arg parameter is passed back to
51     the functions, and can contain a pointer to any caller-specified data.
52

RETURN VALUES

54     These functions return 0 on success or -1 on error.
55

SEE ALSO

57     tls_accept_socket(3), tls_client(3), tls_close(3),
58     tls_config_ocsp_require_stapling(3), tls_configure(3), tls_handshake(3),
59     tls_init(3)
60

HISTORY

62     tls_connect() and tls_connect_socket() appeared in OpenBSD 5.6 and got
63     their final names in OpenBSD 5.7.
64
65     tls_connect_fds() and tls_connect_servername() appeared in OpenBSD 5.7
66     and tls_connect_cbs() in OpenBSD 6.1.
67

AUTHORS

69     Joel Sing <jsing@openbsd.org>
70     Reyk Floeter <reyk@openbsd.org>
71
72     tls_connect_cbs() was written by Tobias Pape <tobias@netshed.de>.
73
74BSD                              July 9, 2018                              BSD
Impressum