PEM_READ_BIO_EX(3SSL)
π PEM_READ_BIO_EX(3SSL) β the OpenSSL glow-up π
okay so bestie, this is <openssl/pem.h>'s lil special edition. it's not a whole new manpage family, it's PEM_read_bio_ex(3SSL) living inside the OpenSSL library docs, and it's the one you call when the regular PEM readers just aren't giving what you need. buckle up π
β¨ NAME β¨
PEM_read_bio_ex, PEM_FLAG_SECURE, PEM_FLAG_EAY_COMPATIBLE, PEM_FLAG_ONLY_B64 β read PEM format files with custom processing π¦
like, PEM but make it yours.
πΈ SYNOPSIS πΈ
#include <openssl/pem.h>
#define PEM_FLAG_SECURE 0x1
#define PEM_FLAG_EAY_COMPATIBLE 0x2
#define PEM_FLAG_ONLY_B64 0x4
int PEM_read_bio_ex(BIO *in, char **name, char **header,
unsigned char **data, long *len, unsigned int flags);
those flag values are literal, bestie. 0x1, 0x2, 0x4. do not freestyle them. π
π DESCRIPTION π
PEM_read_bio_ex() reads in PEM formatted data from an input BIO, and it hands you back three things: the name of the type of contained data, the header information regarding the possibly encrypted data, and the binary data payload (after base64 decoding). yes, it does the base64 decoding for you, you're welcome π«Ά
real talk: it should generally only be used to implement PEM_read_bio_-family functions for specific data types or other usage. but it is exposed, so that you get greater flexibility over how processing is performed, if needed. so basically: it's a power tool, not a snack.
now the flags, one by one, because we don't skip π§
- if
PEM_FLAG_SECUREis set, the intermediate buffers used to read in lines of input are allocated from the secure heap. security girlie behavior, we love to see it. - if
PEM_FLAG_EAY_COMPATIBLEis set, a simple algorithm is used to remove whitespace and control characters from the end of each line, so as to be compatible with the historical behavior ofPEM_read_bio(). it's giving "nostalgia tour" π - if
PEM_FLAG_ONLY_B64is set, all characters are required to be valid base64 characters (or newlines); non-base64 characters are treated as end of input. strict. picky. iconic. - if neither
PEM_FLAG_EAY_COMPATIBLEorPEM_FLAG_ONLY_B64is set, control characters are ignored. chill mode β¨ - if both
PEM_FLAG_EAY_COMPATIBLEandPEM_FLAG_ONLY_B64are set, an error is returned; these options are not compatible with each other. they're exes, okay, they cannot be in the same room π
π NOTES π
the caller must release the storage allocated for *name, *header, and *data. you don't get to just walk away from your malloc'd children. π
- if
PEM_FLAG_SECUREwas set, useOPENSSL_secure_free(); - otherwise,
OPENSSL_free()is used.
get the free call matching the flag, or it's over for you. no cap.
β RETURN VALUES β
PEM_read_bio_ex() returns 1 for success or 0 for failure. that's it, that's the whole vibe check. one or zero. slay or don't.
π₯ SEE ALSO π₯
go read that one too, she's the cousin π
π HISTORY π
The PEM_read_bio_ex() function was added in OpenSSL 1.1.1. so she's not ancient, she's just seasoned. periodt.
π COPYRIGHT π
Copyright 2017 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>.
(read the license bestie, it's the rules, fr fr)
and that's the whole page!! β¨ this was from OpenSSL version 4.0.3, dated 2026-09-29, filed under PEM_READ_BIO_EX(3SSL) β mwah, go forth and read your PEMs responsibly ππ¦πΈ
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms