BIO(7ossl)
π BIO(7ossl) β the OpenSSL one, yeah that one π
okay so bestie, grab a snack π because we're about to talk about BIO, and honestly? It's kind of the moment. This is the OpenSSL manual page for bio, and it's lowkey iconic once it clicks. Let's go. β¨
π NAME π
bio β Basic I/O abstraction. That's it, that's the whole vibe. π¦
β¨ SYNOPSIS β¨
#include <openssl/bio.h>
π DESCRIPTION π
So a BIO is an I/O abstraction β meaning it hides, like, so many of the underlying I/O details from your application. π The way that works: if your app does its I/O through a BIO, it can transparently handle SSL connections, unencrypted network connections, and file I/O. Same code, different plumbing. Main character energy fr fr. π
There are two types of BIO, and you gotta know them both:
- a source/sink BIO
- a filter BIO
As the name implies (the name is doing a lot of work here, and honestly? slay), a source/sink BIO is a source and/or sink of data. Examples include a socket BIO and a file BIO. π§
A filter BIO takes data from one BIO and passes it through to another BIO, or through to the application. The data may be left unmodified (for example a message digest BIO) or it may be translated (for example an encryption BIO). And here's the cute part: the effect of a filter BIO may change depending on which I/O operation it's performing β for example, an encryption BIO will encrypt data if it's being written to, and decrypt data if it's being read from. It's giving dual-threat. π
BIOs can be joined together to form a chain (and yes, a single BIO counts as a chain with one component β everybody's a chain if you believe hard enough π«Ά). A chain normally consists of one source/sink BIO and one or more filter BIOs. Data read from or written to the first BIO then traverses the chain to the end (normally a source/sink BIO). Like a little data parade. π
Some BIOs (such as memory BIOs) can be used immediately after calling BIO_new(). Others (such as file BIOs) need some additional initialization β and frequently a utility function exists to create and initialize such BIOs. Convenient! Obsessed. β
β οΈ okay important, listen up: if BIO_free() is called on a BIO chain it will only free one BIO, which results in a memory leak. Not cute. Not the vibe. π
Calling BIO_free_all() on a single BIO has the same effect as calling BIO_free() on it β other than the discarded return value. Same energy, different name. π
Normally the type argument is supplied by a function which returns a pointer to a BIO_METHOD. And there's a naming convention for such functions, so you can clock them instantly: a source/sink BIO typically starts with BIO_s_ and a filter BIO with BIO_f_. iykyk π
π₯ TCP Fast Open π₯
TCP Fast Open (RFC7413), abbreviated "TFO", is supported by the BIO interface since OpenSSL 3.2. TFO is supported in the following operating systems:
- Linux kernel 3.13 and later, where TFO is enabled by default. π§
- Linux kernel 4.11 and later, using
TCP_FASTOPEN_CONNECT. - FreeBSD 10.3 to 11.4, supports server TFO only.
- FreeBSD 12.0 and later, supports both client and server TFO. π₯
- macOS 10.14 and later. π
Each operating system has a slightly different API for TFO. Please refer to the operating systems' API documentation when using sockets directly. (Like, actually read it. Don't just guess. π)
πΈ EXAMPLES πΈ
Create a memory BIO β look how easy this is, bestie:
BIO *mem = BIO_new(BIO_s_mem());
That's it. That's the whole thing. Ate. π
π¦ SEE ALSO π¦
BIO_ctrl(3)BIO_f_base64(3)BIO_f_buffer(3)BIO_f_cipher(3)BIO_f_md(3)BIO_f_null(3)BIO_f_ssl(3)BIO_f_readbuffer(3)BIO_find_type(3)BIO_get_conn_mode(3)BIO_new(3)BIO_new_bio_pair(3)BIO_push(3)BIO_read_ex(3)BIO_s_accept(3)BIO_s_bio(3)BIO_s_connect(3)BIO_s_fd(3)BIO_s_file(3)BIO_s_mem(3)BIO_s_null(3)BIO_s_socket(3)BIO_set_callback(3)BIO_set_conn_mode(3)BIO_set_tfo(3)BIO_set_tfo_accept(3)BIO_should_retry(3)
π COPYRIGHT π
Copyright 2000-2022 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 page! This one's from OpenSSL 3.5.0, dated 2026-09-25 β so go forth, chain those BIOs, and please, for the love of everything, don't leak memory. love u, bye! π«Άβ¨πΈ
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 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