1e71b7053SJung-uk Kim=pod 2e71b7053SJung-uk Kim 3e71b7053SJung-uk Kim=head1 NAME 4e71b7053SJung-uk Kim 5e71b7053SJung-uk KimSSL_do_handshake - perform a TLS/SSL handshake 6e71b7053SJung-uk Kim 7e71b7053SJung-uk Kim=head1 SYNOPSIS 8e71b7053SJung-uk Kim 9e71b7053SJung-uk Kim #include <openssl/ssl.h> 10e71b7053SJung-uk Kim 11e71b7053SJung-uk Kim int SSL_do_handshake(SSL *ssl); 12e71b7053SJung-uk Kim 13e71b7053SJung-uk Kim=head1 DESCRIPTION 14e71b7053SJung-uk Kim 15e71b7053SJung-uk KimSSL_do_handshake() will wait for a SSL/TLS handshake to take place. If the 16e71b7053SJung-uk Kimconnection is in client mode, the handshake will be started. The handshake 17e71b7053SJung-uk Kimroutines may have to be explicitly set in advance using either 18e71b7053SJung-uk KimL<SSL_set_connect_state(3)> or 19e71b7053SJung-uk KimL<SSL_set_accept_state(3)>. 20e71b7053SJung-uk Kim 21e71b7053SJung-uk Kim=head1 NOTES 22e71b7053SJung-uk Kim 23e71b7053SJung-uk KimThe behaviour of SSL_do_handshake() depends on the underlying BIO. 24e71b7053SJung-uk Kim 25e71b7053SJung-uk KimIf the underlying BIO is B<blocking>, SSL_do_handshake() will only return 26e71b7053SJung-uk Kimonce the handshake has been finished or an error occurred. 27e71b7053SJung-uk Kim 2858f35182SJung-uk KimIf the underlying BIO is B<nonblocking>, SSL_do_handshake() will also return 29e71b7053SJung-uk Kimwhen the underlying BIO could not satisfy the needs of SSL_do_handshake() 30e71b7053SJung-uk Kimto continue the handshake. In this case a call to SSL_get_error() with the 31e71b7053SJung-uk Kimreturn value of SSL_do_handshake() will yield B<SSL_ERROR_WANT_READ> or 32e71b7053SJung-uk KimB<SSL_ERROR_WANT_WRITE>. The calling process then must repeat the call after 33e71b7053SJung-uk Kimtaking appropriate action to satisfy the needs of SSL_do_handshake(). 3458f35182SJung-uk KimThe action depends on the underlying BIO. When using a nonblocking socket, 35e71b7053SJung-uk Kimnothing is to be done, but select() can be used to check for the required 36e71b7053SJung-uk Kimcondition. When using a buffering BIO, like a BIO pair, data must be written 37e71b7053SJung-uk Kiminto or retrieved out of the BIO before being able to continue. 38e71b7053SJung-uk Kim 39e71b7053SJung-uk Kim=head1 RETURN VALUES 40e71b7053SJung-uk Kim 41e71b7053SJung-uk KimThe following return values can occur: 42e71b7053SJung-uk Kim 43e71b7053SJung-uk Kim=over 4 44e71b7053SJung-uk Kim 45e71b7053SJung-uk Kim=item Z<>0 46e71b7053SJung-uk Kim 47e71b7053SJung-uk KimThe TLS/SSL handshake was not successful but was shut down controlled and 48e71b7053SJung-uk Kimby the specifications of the TLS/SSL protocol. Call SSL_get_error() with the 49e71b7053SJung-uk Kimreturn value B<ret> to find out the reason. 50e71b7053SJung-uk Kim 51e71b7053SJung-uk Kim=item Z<>1 52e71b7053SJung-uk Kim 53e71b7053SJung-uk KimThe TLS/SSL handshake was successfully completed, a TLS/SSL connection has been 54e71b7053SJung-uk Kimestablished. 55e71b7053SJung-uk Kim 56e71b7053SJung-uk Kim=item E<lt>0 57e71b7053SJung-uk Kim 58e71b7053SJung-uk KimThe TLS/SSL handshake was not successful because a fatal error occurred either 59e71b7053SJung-uk Kimat the protocol level or a connection failure occurred. The shutdown was 6017f01e99SJung-uk Kimnot clean. It can also occur if action is needed to continue the operation 6158f35182SJung-uk Kimfor nonblocking BIOs. Call SSL_get_error() with the return value B<ret> 62e71b7053SJung-uk Kimto find out the reason. 63e71b7053SJung-uk Kim 64e71b7053SJung-uk Kim=back 65e71b7053SJung-uk Kim 66e71b7053SJung-uk Kim=head1 SEE ALSO 67e71b7053SJung-uk Kim 68e71b7053SJung-uk KimL<SSL_get_error(3)>, L<SSL_connect(3)>, 69e71b7053SJung-uk KimL<SSL_accept(3)>, L<ssl(7)>, L<bio(7)>, 70e71b7053SJung-uk KimL<SSL_set_connect_state(3)> 71e71b7053SJung-uk Kim 72e71b7053SJung-uk Kim=head1 COPYRIGHT 73e71b7053SJung-uk Kim 7417f01e99SJung-uk KimCopyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. 75e71b7053SJung-uk Kim 76*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 77e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 78e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 79e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 80e71b7053SJung-uk Kim 81e71b7053SJung-uk Kim=cut 82