1SSL_CONNECT(3)                      OpenSSL                     SSL_CONNECT(3)
2
3
4

NAME

6       SSL_connect - initiate the TLS/SSL handshake with an TLS/SSL server
7

SYNOPSIS

9        #include <openssl/ssl.h>
10
11        int SSL_connect(SSL *ssl);
12

DESCRIPTION

14       SSL_connect() initiates the TLS/SSL handshake with a server. The
15       communication channel must already have been set and assigned to the
16       ssl by setting an underlying BIO.
17

NOTES

19       The behaviour of SSL_connect() depends on the underlying BIO.
20
21       If the underlying BIO is blocking, SSL_connect() will only return once
22       the handshake has been finished or an error occurred.
23
24       If the underlying BIO is nonblocking, SSL_connect() will also return
25       when the underlying BIO could not satisfy the needs of SSL_connect() to
26       continue the handshake, indicating the problem by the return value -1.
27       In this case a call to SSL_get_error() with the return value of
28       SSL_connect() will yield SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE.
29       The calling process then must repeat the call after taking appropriate
30       action to satisfy the needs of SSL_connect().  The action depends on
31       the underlying BIO. When using a nonblocking socket, nothing is to be
32       done, but select() can be used to check for the required condition.
33       When using a buffering BIO, like a BIO pair, data must be written into
34       or retrieved out of the BIO before being able to continue.
35
36       Many systems implement Nagle's algorithm by default which means that it
37       will buffer outgoing TCP data if a TCP packet has already been sent for
38       which no corresponding ACK has been received yet from the peer. This
39       can have performance impacts after a successful TLSv1.3 handshake or a
40       successful TLSv1.2 (or below) resumption handshake, because the last
41       peer to communicate in the handshake is the client. If the client is
42       also the first to send application data (as is typical for many
43       protocols) then this data could be buffered until an ACK has been
44       received for the final handshake message.
45
46       The TCP_NODELAY socket option is often available to disable Nagle's
47       algorithm. If an application opts to disable Nagle's algorithm
48       consideration should be given to turning it back on again later if
49       appropriate. The helper function BIO_set_tcp_ndelay() can be used to
50       turn on or off the TCP_NODELAY option.
51

RETURN VALUES

53       The following return values can occur:
54
55       0   The TLS/SSL handshake was not successful but was shut down
56           controlled and by the specifications of the TLS/SSL protocol. Call
57           SSL_get_error() with the return value ret to find out the reason.
58
59       1   The TLS/SSL handshake was successfully completed, a TLS/SSL
60           connection has been established.
61
62       <0  The TLS/SSL handshake was not successful, because a fatal error
63           occurred either at the protocol level or a connection failure
64           occurred. The shutdown was not clean. It can also occur if action
65           is needed to continue the operation for nonblocking BIOs. Call
66           SSL_get_error() with the return value ret to find out the reason.
67

SEE ALSO

69       SSL_get_error(3), SSL_accept(3), SSL_shutdown(3), ssl(7), bio(7),
70       SSL_set_connect_state(3), SSL_do_handshake(3), SSL_CTX_new(3)
71
73       Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
74
75       Licensed under the OpenSSL license (the "License").  You may not use
76       this file except in compliance with the License.  You can obtain a copy
77       in the file LICENSE in the source distribution or at
78       <https://www.openssl.org/source/license.html>.
79
80
81
821.1.1i                            2021-01-26                    SSL_CONNECT(3)
Impressum