SSL_DO_HANDSHAKE(3)
π 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 ofSSL_do_handshake()to continue the handshake. in this case, a call toSSL_get_error(3)with the return value ofSSL_do_handshake()will yieldSSL_ERROR_WANT_READorSSL_ERROR_WANT_WRITE. the calling process then must repeat the call after taking appropriate action to satisfy the needs ofSSL_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. callSSL_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. callSSL_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,0means polite goodbye,1means we're so back. and always β ALWAYS β askSSL_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
- Copyright (c) 2002 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms