BIO(7ossl)

πŸ’… BIO(7ossl) β€” the OpenSSL manual page, bestie edition πŸ¦‹

okay so welcome to BIO(7ossl), the OpenSSL page about Basic I/O abstraction. pull up a chair, grab a strawberry πŸ“, and let's get into it.


✨ NAME ✨

bio β€” Basic I/O abstraction. that's it, that's the whole name. iconic and mysterious.


✨ SYNOPSIS ✨

#include <openssl/bio.h>

that's literally all you need to include. slay.


✨ DESCRIPTION ✨

so a BIO is an I/O abstraction, and what that means is it hides a whole bunch of the underlying I/O details from your application. like, it does the messy work so you don't have to. and the glow-up? if an application uses a BIO for its I/O, it can transparently handle SSL connections, unencrypted network connections, and file I/O. no cap, all three, same interface. πŸ’…

there are two types of BIO, and you need to know them both:

  • a source/sink BIO β€” and yes, as its name implies, it's a source and/or sink of data. examples include a socket BIO and a file BIO. it's giving "where the data lives."
  • a filter BIO β€” this one takes data from one BIO and passes it through to another one, or to the application.

now a filter BIO can leave the data unmodified (for example a message digest BIO) or it can translate it (for example an encryption BIO). and here's the cute part: the effect of a filter BIO may change according to the I/O operation it's performing. so for example, an encryption BIO will encrypt data if it's being written to, and decrypt data if it's being read from. main character energy honestly. πŸ”₯

BIOs can be joined together to form a chain (and a single BIO is just a chain with one component, no big deal). 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 (which is normally a source/sink BIO). it's giving relay race. πŸŽ€

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. lowkey convenient.

⚠️ bestie listen to me. if BIO_free() is called on a BIO chain it will only free one BIO, resulting in a memory leak. that's not a vibe. that's a leak. 😭

calling BIO_free_all() on a single BIO has the same effect as calling BIO_free() on it, other than the discarded return value. so yeah, same thing, just throwing the return value away.

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, iykyk: a source/sink BIO typically starts with BIO_s_ and a filter BIO with BIO_f_. 🧚


🌈 TCP Fast Open 🌈

TCP Fast Open (RFC7413), abbreviated "TFO", is supported by the BIO interface since OpenSSL 3.2. and it's 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. so please refer to the operating systems' API documentation when using sockets directly. don't guess, okay? πŸ™ˆ


✨ EXAMPLES ✨

create a memory BIO, like so:

BIO *mem = BIO_new(BIO_s_mem());

that's the whole example and honestly it ate. πŸ’œ


✨ SEE ALSO ✨

go read these too, they're all part of the family:


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, bestie! this was OpenSSL 3.5.9, dated 2026-09-29, and it's filed under BIO(7ossl). mwah πŸ’‹ go free your chains properly (with BIO_free_all(), please, i'm begging). πŸŽ€βœ¨

πŸ“¦ where this page comes from