SSL_WANT(3ossl)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 15.1

πŸ’… SSL_WANT(3ossl) β€” the vibe check your TLS connection needed ✨

okay bestie, so this is the SSL_WANT(3ossl) page from the OpenSSL fam, and it's genuinely so useful β€” it's literally how you find out what your TLS/SSL I/O operation is waiting on. no cap, if you're doing nonblocking I/O you're gonna be obsessed with this one 🫢


🌸 NAME 🌸

SSL_want, SSL_want_nothing, SSL_want_read, SSL_want_write, SSL_want_x509_lookup, SSL_want_retry_verify, SSL_want_async, SSL_want_async_job, SSL_want_client_hello_cb β€” these are the girlies that get you state information about a TLS/SSL I/O operation πŸ’–


✨ SYNOPSIS ✨

#include <openssl/ssl.h>

int SSL_want(const SSL *ssl);
int SSL_want_nothing(const SSL *ssl);
int SSL_want_read(const SSL *ssl);
int SSL_want_write(const SSL *ssl);
int SSL_want_x509_lookup(const SSL *ssl);
int SSL_want_retry_verify(const SSL *ssl);
int SSL_want_async(const SSL *ssl);
int SSL_want_async_job(const SSL *ssl);
int SSL_want_client_hello_cb(const SSL *ssl);

πŸ¦‹ DESCRIPTION πŸ¦‹

So SSL_want() hands you the state information for the SSL object ssl. and listen β€” ssl MUST NOT be NULL. like, at all. don't do that to her πŸ™ˆ

The other SSL_want_*() calls? total shortcuts, bestie. each one is just a cute little shortcut for one of the possible states that SSL_want() can return ✨


πŸŽ€ NOTES πŸŽ€

SSL_want() peeks at the internal state information of the SSL object. the return values are similar to what you'd get from SSL_get_error(3). but β€” and this is the important part β€” unlike SSL_get_error(3), which also evaluates the error queue, SSL_want() gets its results by examining an internal state flag only. so the info is only meant to be used for normal operation under nonblocking I/O, periodt πŸ’…

error conditions? not her job. those are not handled here and must be treated using SSL_get_error(3).

and the result returned by SSL_want() should always be consistent with the result of SSL_get_error(3). always bestie, no exceptions 🌈


πŸ‘‘ RETURN VALUES πŸ‘‘

so here's the roster of return values that can currently occur for SSL_want() β€” get into it:

  • SSL_NOTHING β€” there is no data to be written or to be read. a whole lotta nothing, but make it valid πŸ’€
  • SSL_WRITING β€” there are data in the SSL buffer that must be written to the underlying BIO layer in order to complete the actual SSL_*() operation. a call to SSL_get_error(3) should return SSL_ERROR_WANT_WRITE.
  • SSL_READING β€” more data must be read from the underlying BIO layer in order to complete the actual SSL_*() operation. a call to SSL_get_error(3) should return SSL_ERROR_WANT_READ.
  • SSL_X509_LOOKUP β€” the operation did not complete because an application callback set by SSL_CTX_set_client_cert_cb() has asked to be called again. a call to SSL_get_error(3) should return SSL_ERROR_WANT_X509_LOOKUP.
  • SSL_RETRY_VERIFY β€” the operation did not complete because a certificate verification callback has asked to be called again via SSL_set_retry_verify(3). a call to SSL_get_error(3) should return SSL_ERROR_WANT_RETRY_VERIFY.
  • SSL_ASYNC_PAUSED β€” an asynchronous operation partially completed and was then paused. see SSL_get_all_async_fds(3). a call to SSL_get_error(3) should return SSL_ERROR_WANT_ASYNC.
  • SSL_ASYNC_NO_JOBS β€” the asynchronous job could not be started because there were no async jobs available in the pool (see ASYNC_init_thread(3)). a call to SSL_get_error(3) should return SSL_ERROR_WANT_ASYNC_JOB.
  • SSL_CLIENT_HELLO_CB β€” the operation did not complete because an application callback set by SSL_CTX_set_client_hello_cb() has asked to be called again. a call to SSL_get_error(3) should return SSL_ERROR_WANT_CLIENT_HELLO_CB.

and for the shortcut squad β€” SSL_want_nothing(), SSL_want_read(), SSL_want_write(), SSL_want_x509_lookup(), SSL_want_retry_verify(), SSL_want_async(), SSL_want_async_job(), and SSL_want_client_hello_cb() β€” they return 1 when the corresponding condition is true, or 0 otherwise. iconic, simple, love that for them πŸ“


πŸ’œ QUIC-SPECIFIC CONSIDERATIONS πŸ’œ

for QUIC, these functions relate only to the TLS handshake layer. that's it, that's the whole note, but it matters so don't skip it ✨


πŸ”₯ SEE ALSO πŸ”₯

ssl(7), SSL_get_error(3) β€” go read these next, they're the supporting cast and they ate πŸ‘‘


⭐ HISTORY ⭐

the SSL_want_client_hello_cb() function and the SSL_CLIENT_HELLO_CB return value were added in OpenSSL 1.1.1. a lil throwback moment πŸŽ€


Copyright 2001-2023 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that's the whole page bestie!! this one's from OpenSSL 3.5.6, dated 2026-04-07, filed under SSL_WANT(3ossl) β€” go forth and check your state flags responsibly πŸ’…πŸ’–βœ¨

πŸ“¦ where this page comes from