BIO_GET_DATA(3SSL)

πŸ’– BIO_GET_DATA β€” the OpenSSL 3SSL manual, but make it a group chat πŸ’–

bestie. you found the page. the manual name is right there in the header (3SSL, OpenSSL's own section), and honestly? this is the state-management lore for custom BIOs. sit down, hydrate, we're doing this. 🫢


🌸 NAME 🌸

BIO_set_data, BIO_get_data, BIO_set_init, BIO_get_init, BIO_set_shutdown, BIO_get_shutdown β€” the functions for managing BIO state information. that's it, that's the whole vibe. ✨


✨ 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);

look at those little signatures. so demure. so mindful. πŸ’…


πŸ’… DESCRIPTION πŸ’…

okay so here's the tea: these functions are the ones you reach for when you're implementing a custom BIO. not for casuals. for builders. for you. πŸ‘‘

Here's each one, one by one, no skipping:

  • BIO_set_data() β€” associates the custom data pointed to by ptr with the BIO. and then, later, you can get it back by calling BIO_get_data(). this is the move custom BIOs use to store their implementation-specific information. it's giving "my data, my rules". πŸ’Ύ
  • BIO_set_init() β€” sets the value of the BIO's "init" flag, which is how the BIO says whether initialisation has been completed for it or not. a nonzero value = initialisation is complete. zero = it is not. often initialisation finishes during the initial construction of the BIO. but for some BIOs? it doesn't complete until after additional steps have happened β€” for example, through calling custom ctrls. character development arc fr. 🌱
  • BIO_get_init() β€” returns the value of that "init" flag. the vibe check. the status report. ✨
  • BIO_set_shutdown() and BIO_get_shutdown() β€” set and get the state of this BIO's shutdown (i.e. BIO_CLOSE) flag. and if that flag is set, then the underlying resource is also closed when the BIO is freed. closure, literally. πŸŽ€

🚨 WARNINGS 🚨

girl. listen. Do not use BIO_set_data(), BIO_get_data(), BIO_set_init(), BIO_get_init() outside the implementation of a custom BIO.

periodt. and it gets worse: calling BIO_set_data() on an existing BIO implementation with data that it does not expect will lead to unexpected results. not "cute surprise" unexpected. "why is everything on fire" unexpected. πŸ’€ do not do it. i'm not playing. πŸ™ˆ


πŸ”₯ 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. yes, NULL is a valid answer, it's just a shy one. πŸ¦‹
  • BIO_get_init() β€” returns the state of the BIO's init flag.
  • BIO_get_shutdown() β€” returns the stat β€” like, the state β€” of the BIO's shutdown (i.e. BIO_CLOSE) flag.

πŸ‘€ SEE ALSO πŸ‘€

go read them. iykyk. πŸ“š


πŸ•°οΈ HISTORY πŸ•°οΈ

The functions described here were added in OpenSSL 1.1.0. so they've been iconic for a while now. ⭐


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 page, bestie!! πŸ’– no cap, you now know exactly how BIO state info works, and that's main character energy. this was the BIO_GET_DATA manual from OpenSSL version 4.0.3, dated 2026-09-29 β€” go forth and implement your custom BIO responsibly. mwah. πŸŽ€βœ¨πŸ«Ά

πŸ“¦ where this page comes from