SSL_PENDING(3ossl)
π SSL_PENDING β check for readable bytes buffered in an SSL object π
okay so this is SSL_PENDING(3ossl) from the OpenSSL fam, and honestly? it's giving "is there a snack in the fridge or not" energy and i'm obsessed. let's get into it bestie β¨
πΈ NAME πΈ
SSL_pending, SSL_has_pending β the two functions that tell you whether there are readable bytes chillin' in the buffer inside an SSL object π«Ά
β¨ SYNOPSIS β¨
#include <openssl/ssl.h>
int SSL_pending(const SSL *ssl);
int SSL_has_pending(const SSL *s);
literally two lines, no drama, we love to see it π
π¦ DESCRIPTION π¦
so the way this works: data arrives from the peer in whole blocks called records. a whole record gets processed (like, decrypted, bestie π
) in one go, and then OpenSSL buffers it until your app actually reads it with a call to SSL_read_ex(3) or SSL_read(3). that's the whole pipeline. no cap.
SSL_pending() returns the number of bytes that have been processed, buffered, and are available inside ssl for immediate read. that's your ready-to-eat snack count π
now here's where it gets spicy πΆοΈ β if the SSL object's read_ahead flag is set (peep SSL_CTX_set_read_ahead(3)), then additional protocol bytes beyond the current record may have been read, containing more TLS/SSL records. this also applies to DTLS and pipelining (see SSL_CTX_set_split_send_fragment(3)). those extra bytes get buffered by OpenSSL but stay unprocessed until they're needed. and because they're still unprocessed, SSL_pending() straight up ignores them π
so likeβ¦ it's totally possible for there to be no more bytes readable from the underlying BIO (because OpenSSL already slurped them up) AND for SSL_pending() to return 0 β even though readable application data bytes are available, because the data is sitting in unprocessed buffered records. yeah. that's the vibe check you gotta be aware of π
SSL_has_pending() returns 1 if s has buffered data (whether processed or unprocessed), and 0 otherwise. icon behavior, but with a caveat π
heads up: it is possible forSSL_has_pending()to return1, and then a subsequent call toSSL_read_ex()orSSL_read()to return no data β because the unprocessed buffered data, when it did get processed, yielded no application data (for example, this can happen during renegotiation). and in that same scenario,SSL_has_pending()can keep returning1even after anSSL_read_ex()orSSL_read()call, because the buffered unprocessed data isn't processable yet (e.g. because OpenSSL has only received a partial record so far). π
β RETURN VALUES β
SSL_pending()β returns the number of buffered and processed application data bytes that are pending and available for immediate read. slay π₯SSL_has_pending()β returns1if there's buffered record data in theSSLobject, and0otherwise. periodt π
π SEE ALSO π
SSL_read_ex(3), SSL_read(3), SSL_CTX_set_read_ahead(3), SSL_CTX_set_split_send_fragment(3), ssl(7)
go read those too, iykyk π§
π HISTORY π
the SSL_has_pending() function was added in OpenSSL 1.1.0. so it's been around for a hot minute π
π COPYRIGHT π
Copyright 2000-2020 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 π«Ά version 3.5.0, dated 2026-09-25, brought to you by the SSL_PENDING(3ossl) manual β now go check your buffers, main character πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms