SSL_do_handshake.pod 2.5 KB

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