PEM_READ_BIO_EX(3ossl)
π PEM_READ_BIO_EX π
okay bestie so this one lives in the OpenSSL fam, and it's literally the manual page for PEM_read_bio_ex, PEM_FLAG_SECURE, PEM_FLAG_EAY_COMPATIBLE, and PEM_FLAG_ONLY_B64 β aka read PEM format files with custom processing. yes that's the whole vibe. custom processing. we love a bespoke read. β¨
β¨ SYNOPSIS β¨
like here's the tea, go ahead and include this:
#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);
πΈ DESCRIPTION πΈ
so PEM_read_bio_ex() reads in PEM formatted data from an input BIO, and it hands you back three-ish things: the name of the type of contained data, the header info about the possibly-encrypted data, and the binary data payload (after base64 decoding, obvi). ngl, you should generally only use it to implement PEM_read_bio_-family functions for specific data types or other usage β but it's exposed to y'all so you get greater flexibility over how processing is performed, if you need it. π
- if
PEM_FLAG_SECUREis set β the intermediate buffers used to read in lines of input are allocated from the secure heap. fancy. - 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 legacy respect. π«Ά - 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. - if neither
PEM_FLAG_EAY_COMPATIBLEnorPEM_FLAG_ONLY_B64is set β control characters are ignored. π - if both
PEM_FLAG_EAY_COMPATIBLEandPEM_FLAG_ONLY_B64are set β an error is returned; these options are not compatible with each other. periodt. pick a lane bestie π
π NOTES π
the caller must release the storage allocated for *name, *header, and *data. like pls don't leak, that's not the vibe.
ifPEM_FLAG_SECUREwas set, useOPENSSL_secure_free(); otherwise,OPENSSL_free()is used. get it right or the memory will simply haunt you π
β RETURN VALUES β
PEM_read_bio_ex() returns 1 for success or 0 for failure. that's it. binary queen. π
π SEE ALSO π
PEM_bytes_read_bio(3)β go read her too, iykyk
π¦ HISTORY π¦
the PEM_read_bio_ex() function was added in OpenSSL 1.1.1. a classic. an icon. she's been here. β¨
π 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>.
and that's the whole page bestie, no cap β this one's from 3.5.9, dated 2026-09-29, and yes she's still serving PEM_READ_BIO_EX(3ossl) energy π
ππΈ
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms