BIO_GET_DATA(3ossl)

πŸ’– BIO_GET_DATA(3ossl) πŸ’–

okay so bestie, welcome to BIO_GET_DATA(3ossl) β€” this is your lil OpenSSL cheat sheet for managing BIO state info. it's giving "backstage pass to a custom BIO" energy and honestly? we're obsessed. πŸŽ€


✨ NAME ✨

BIO_set_data, BIO_get_data, BIO_set_init, BIO_get_init, BIO_set_shutdown, BIO_get_shutdown β€” the whole squad of functions for managing BIO state information. 🌸


✨ SYNOPSIS ✨

#include <openssl/bio.h>

void BIO_set_data(BIO *a, void *ptr);
void *BIO_get_data(BIO *a);
void BIO_set_init(BIO *a, int init);
int BIO_get_init(BIO *a);
void BIO_set_shutdown(BIO *a, int shut);
int BIO_get_shutdown(BIO *a);

✨ DESCRIPTION ✨

so like, these functions are for when you're implementing a custom BIO. main character behavior only. πŸ‘‘

The BIO_set_data() function associates the custom data pointed to by ptr with the BIO. that data can later be retrieved via a call to BIO_get_data(). custom BIOs use this for storing implementation specific information. it's basically the BIO's little purse where it keeps its stuff. 🫢

The BIO_set_init() function sets the value of the BIO's "init" flag, which tells you whether initialisation has been completed for this BIO or not. a nonzero value means initialisation is complete, and zero means it is not. often initialisation will complete during initial construction of the BIO. for some BIOs though, initialisation may not complete until after additional steps have occurred β€” for example through calling custom ctrls. and BIO_get_init() returns the value of that "init" flag. πŸ’…

The BIO_set_shutdown() and BIO_get_shutdown() functions set and get the state of this BIO's shutdown (i.e. BIO_CLOSE) flag. if it's set, then the underlying resource is also closed when the BIO is freed. lowkey important, don't sleep on it. πŸ”₯


✨ WARNINGS ✨

bestie. no. πŸ›‘

Do not use BIO_set_data(), BIO_get_data(), BIO_set_init(), BIO_get_init() outside the implementation of a custom BIO. Calling BIO_set_data() on an existing BIO implementation with data that it does not expect will lead to unexpected results. like, unexpected unexpected. πŸ’€


✨ RETURN VALUES ✨

  • BIO_get_data() returns a pointer to the implementation specific custom data associated with this BIO, or NULL if none has been set. πŸ™ˆ
  • BIO_get_init() returns the state of the BIO's init flag. ⭐
  • BIO_get_shutdown() returns the stat of the BIO's shutdown (i.e. BIO_CLOSE) flag. (yes, "stat" β€” that's literally what the source says, i'm just the messenger πŸŽ€)

✨ SEE ALSO ✨

bio(7), BIO_meth_new(3)


✨ HISTORY ✨

The functions described here were added in OpenSSL 1.1.0. vintage but still slaying. πŸ¦‹


Copyright 2016-2026 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 was BIO_GET_DATA(3ossl) from OpenSSL 3.5.9, dated 2026-09-29 β€” thanks for coming to my TED talk, mwah, go implement a custom BIO responsibly βœ¨πŸŽ€πŸ’…

πŸ“¦ where this page comes from