OPENSSL_INIT_CRYPTO(3)

πŸ“¦
version 4.4.0 Β· 2 versions
, in arch rolling

πŸ’– OPENSSL_INIT_CRYPTO πŸ’–

okay bestie, real talk β€” this one's from the Library Functions Manual, and it's about that crypto library startup/shutdown vibe. buckle up πŸŽ€


✨ NAME ✨

OPENSSL_init_crypto, OPENSSL_init, OPENSSL_cleanup β€” the whole "wake up the crypto library" and "put the crypto library to bed" situation πŸ’…


🌸 SYNOPSIS 🌸

library β€œlibcrypto” #include <openssl/crypto.h>

int
OPENSSL_init_crypto(uint64_t options, const void *dummy);

void
OPENSSL_init(void);

void
OPENSSL_cleanup(void);

she's giving very specific function signatures, and we respect her for it 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so first thing β€” OPENSSL_init_crypto() and OPENSSL_init() are deprecated. like, genuinely deprecated. it is never useful for an application program to call either of them explicitly. not once. not ever. the audacity of some code, honestly 😭

the library just calls OPENSSL_init_crypto() internally, all by itself, with an options argument of 0, whenever it needs to. and the safest assumption? literally any function might do it. so don't act surprised. 🧚

want to enable or disable the standard configuration file? use OPENSSL_config(3) or OPENSSL_no_config(3) instead, respectively, bestie. want to load a non-standard configuration file? that's a whole different thing β€” go see CONF_modules_load_file(3).

now, if OPENSSL_init_crypto() gets called before any other crypto or ssl functions, the crypto library gets initialised by allocating various internal resources β€” in particular, it calls ERR_load_crypto_strings(3). iconic behaviour tbh πŸ‘‘

the following options are supported:

  • OPENSSL_INIT_LOAD_CONFIG β€” at the end of the initialization, call OPENSSL_config(3) with a NULL argument, loading the default configuration file. πŸ“‚
  • OPENSSL_INIT_NO_LOAD_CONFIG β€” ignore any later calls to OPENSSL_config(3). like, blocked. 🚫

the other options flags defined by OpenSSL are all ignored by LibreSSL. all of them. and the dummy argument has no effect whatsoever β€” it's literally just vibing there πŸ’€

if this function is called more than once, none of the calls except the first one have any effect. first one ate and left no crumbs πŸ“

OPENSSL_init() has no effect at all. no notes. 🌈

OPENSSL_cleanup() frees process-wide resources allocated by libcrypto. and listen β€” it is intended exclusively for the final shutdown of libcrypto in a process. exclusively. before you call it, the application has to make sure all other threads that may use libcrypto have stopped, and that no library component will use libcrypto again. after it returns, libcrypto cannot be reinitialized and no libcrypto or libssl function may be called. like, that's it, it's over, doors closed πŸ”₯

🚨 OPENSSL_cleanup() is not a replacement for deprecated cleanup functions such as CRYPTO_cleanup_all_ex_data(3), and it must not be called after individual cryptographic operations, or when an individual library component is finished with libcrypto. so please, do not use it like that. i'm begging πŸ™ˆ

πŸ’œ RETURN VALUES πŸ’œ

OPENSSL_init_crypto() is intended to return 1 on success or 0 on error. intended. keep that word in mind, bestie, because the BUGS section is about to have opinions 😭


⭐ SEE ALSO ⭐

go read those, iykyk 🌸


πŸ‘‘ HISTORY πŸ‘‘

  • OPENSSL_init() first appeared in OpenSSL 1.0.0e and has been available since OpenBSD 5.3. it stopped having any effect in OpenSSL 1.1.1 and in OpenBSD 5.6. glow-down of the century, lowkey πŸ’€
  • OPENSSL_init_crypto() first appeared in OpenSSL 1.1.0 and has been available since OpenBSD 6.3. πŸ¦‹
  • OPENSSL_cleanup() first appeared in OpenSSL 1.1.0 and has been available since OpenBSD 7.2. πŸŽ€

πŸ’€ BUGS πŸ’€

okay this is the part where we get real, bestie. OPENSSL_init_crypto() silently ignores almost all kinds of errors. almost all of them. 😭

in particular, if memory allocation fails, initialisation is likely to remain incomplete, the library may be in an inconsistent internal state β€” and the return value will usually indicate success anyway. the way that it just lies to your face πŸ’…

there is no way for the application program to find out whether library initialisation is actually complete, nor to get back to a consistent state if it isn't. not one way. not even a little one. πŸ™ˆ

highkey the most relatable bug: says "yeah all good" while absolutely not being all good. main character energy, terrible engineering energy.

kay that's the whole page, bestie β€” every flag, every caveat, every slightly cursed historical detail, all accounted for πŸ’–

this cutie dropped as part of Debian, dated August 30, 2026 β€” and that's the sign-off, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from
  • arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms