168651Skris=pod 268651Skris 368651Skris=head1 NAME 468651Skris 568651SkrisSSL_connect - initiate the TLS/SSL handshake with an TLS/SSL server 668651Skris 768651Skris=head1 SYNOPSIS 868651Skris 968651Skris #include <openssl/ssl.h> 1068651Skris 1168651Skris int SSL_connect(SSL *ssl); 1268651Skris 1368651Skris=head1 DESCRIPTION 1468651Skris 1568651SkrisSSL_connect() initiates the TLS/SSL handshake with a server. The communication 1668651Skrischannel must already have been set and assigned to the B<ssl> by setting an 1768651Skrisunderlying B<BIO>. 1868651Skris 1968651Skris=head1 NOTES 2068651Skris 2168651SkrisThe behaviour of SSL_connect() depends on the underlying BIO. 2268651Skris 2368651SkrisIf the underlying BIO is B<blocking>, SSL_connect() will only return once the 2468651Skrishandshake has been finished or an error occurred. 2568651Skris 2668651SkrisIf the underlying BIO is B<non-blocking>, SSL_connect() will also return 2768651Skriswhen the underlying BIO could not satisfy the needs of SSL_connect() 28120631Snectarto continue the handshake, indicating the problem by the return value -1. 29120631SnectarIn this case a call to SSL_get_error() with the 3068651Skrisreturn value of SSL_connect() will yield B<SSL_ERROR_WANT_READ> or 3168651SkrisB<SSL_ERROR_WANT_WRITE>. The calling process then must repeat the call after 3268651Skristaking appropriate action to satisfy the needs of SSL_connect(). 3368651SkrisThe action depends on the underlying BIO. When using a non-blocking socket, 3468651Skrisnothing is to be done, but select() can be used to check for the required 3568651Skriscondition. When using a buffering BIO, like a BIO pair, data must be written 3668651Skrisinto or retrieved out of the BIO before being able to continue. 3768651Skris 3868651Skris=head1 RETURN VALUES 3968651Skris 4068651SkrisThe following return values can occur: 4168651Skris 4268651Skris=over 4 4368651Skris 44264331Sjkim=item Z<>0 4568651Skris 4668651SkrisThe TLS/SSL handshake was not successful but was shut down controlled and 4768651Skrisby the specifications of the TLS/SSL protocol. Call SSL_get_error() with the 4868651Skrisreturn value B<ret> to find out the reason. 4968651Skris 50264331Sjkim=item Z<>1 51264331Sjkim 52264331SjkimThe TLS/SSL handshake was successfully completed, a TLS/SSL connection has been 53264331Sjkimestablished. 54264331Sjkim 5572613Skris=item E<lt>0 5668651Skris 5768651SkrisThe TLS/SSL handshake was not successful, because a fatal error occurred either 5868651Skrisat the protocol level or a connection failure occurred. The shutdown was 5968651Skrisnot clean. It can also occur of action is need to continue the operation 6068651Skrisfor non-blocking BIOs. Call SSL_get_error() with the return value B<ret> 6168651Skristo find out the reason. 6268651Skris 6368651Skris=back 6468651Skris 6568651Skris=head1 SEE ALSO 6668651Skris 6768651SkrisL<SSL_get_error(3)|SSL_get_error(3)>, L<SSL_accept(3)|SSL_accept(3)>, 6876866SkrisL<SSL_shutdown(3)|SSL_shutdown(3)>, L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)>, 6976866SkrisL<SSL_set_connect_state(3)|SSL_set_connect_state(3)>, 70100936SnectarL<SSL_do_handshake(3)|SSL_do_handshake(3)>, 7176866SkrisL<SSL_CTX_new(3)|SSL_CTX_new(3)> 7268651Skris 7368651Skris=cut 74