SSL_DO_HANDSHAKE(3)

πŸ“¦
version 4.4.0 Β· 2 versions
, in arch rolling

πŸ’… SSL_do_handshake(3) β€” perform a TLS/SSL handshake ✨

okay so bestie, you know how every situationship needs a little "what are we" moment before it gets real? that's this function. it's the libssl / libcrypto girlie (yes, from <openssl/ssl.h>) whose whole job is to make two computers formally agree to talk TLS/SSL. no cap, it's giving main character energy for the entire connection. 🫢


πŸŽ€ SYNOPSIS πŸŽ€

library β€œlibssl” libcrypto #include <openssl/ssl.h>

int
SSL_do_handshake(SSL *ssl);

literally one function, one pointer, no drama. the way that signature ate. πŸ’…


✨ DESCRIPTION ✨

SSL_do_handshake() will wait for an SSL/TLS handshake to take place. if the connection is in client mode, the handshake will be started. simple as that, periodt.

the handshake routines may have to be explicitly set in advance using either SSL_set_connect_state(3) or SSL_set_accept_state(3) β€” so like, decide your role first, bestie, don't just show up to the handshake with no plan. πŸ™ˆ

the behaviour of SSL_do_handshake() depends on the underlying BIO. this is the part where you gotta know your vibes:

  • if the underlying BIO is blocking, SSL_do_handshake() will only return once the handshake has been finished or an error occurred. it's the friend who stays on the phone until the whole conversation is over. πŸ’€
  • if the underlying BIO is non-blocking, SSL_do_handshake() will also return when the underlying BIO could not satisfy the needs of SSL_do_handshake() to continue the handshake. in this case, a call to SSL_get_error(3) with the return value of SSL_do_handshake() will yield SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE. the calling process then must repeat the call after taking appropriate action to satisfy the needs of SSL_do_handshake(). yes, you have to keep coming back. it's giving "u up?" energy at 2am. 😭

the action depends on the underlying BIO:

  • when using a non-blocking socket, nothing is to be done, but select(2) can be used to check for the required condition. so like, just sit there and look pretty until your socket is ready. 🌸
  • when using a buffering BIO, like a BIO pair, data must be written into or retrieved out of the BIO before being able to continue. you literally have to hand it the goods first. πŸ“

πŸ’– RETURN VALUES πŸ’–

the following return values can occur β€” know them, memorize them, put them on your vision board:

  • 0 β€” the TLS/SSL handshake was not successful but was shut down controlled and by the specifications of the TLS/SSL protocol. call SSL_get_error(3) with the return value ret to find out the reason. it's a breakup, but a respectful one. πŸ’”
  • 1 β€” the TLS/SSL handshake was successfully completed, and a TLS/SSL connection has been established. SLAY. πŸ”₯πŸ‘‘
  • <0 β€” the TLS/SSL handshake was not successful because either a fatal error occurred at the protocol level or a connection failure occurred. the shutdown was not clean. it can also occur if action is needed to continue the operation for non-blocking BIOs. call SSL_get_error(3) with the return value ret to find out the reason. this is the messy breakup where someone keyed your car. πŸ’€
bestie pls never forget: negative means drama, 0 means polite goodbye, 1 means we're so back. and always β€” ALWAYS β€” ask SSL_get_error(3) for the receipts. 🧾

πŸ¦‹ SEE ALSO πŸ¦‹

the whole friend group, fr fr. iykyk. 🌈


πŸ‘‘ HISTORY πŸ‘‘

SSL_do_handshake() first appeared in SSLeay 0.8.0 and has been available since OpenBSD 2.4. a true icon, been serving since forever. ⭐


okay that's the whole page, go forth and handshake responsibly πŸŽ€βœ¨ β€” mwah, this was Debian's drop from August 25, 2026, and it's literally iconic. πŸ’œπŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from
  • arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms