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