PEM_X509_INFO_READ_BIO_EX(3ossl)
π
PEM_X509_INFO_READ_BIO_EX β or, how to slurp PEM blobs into X509_INFO cuties
okay so this page lives in section 3ossl of the OpenSSL manual, and it's literally the whole glow-up guide for four functions that read PEM-encoded stuff into one or more X509_INFO objects. bestie, if you've ever stared at a .pem file full of -----BEGIN lines and thought "what even is all this", this is your page π
β¨ NAME β¨
PEM_X509_INFO_read_ex, PEM_X509_INFO_read, PEM_X509_INFO_read_bio_ex, PEM_X509_INFO_read_bio β read PEM-encoded data structures into one or more X509_INFO objects. that's the whole vibe π
πΈ SYNOPSIS πΈ
#include <openssl/pem.h>
STACK_OF(X509_INFO) *PEM_X509_INFO_read_ex(FILE *fp, STACK_OF(X509_INFO) *sk,
pem_password_cb *cb, void *u,
OSSL_LIB_CTX *libctx,
const char *propq);
STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
pem_password_cb *cb, void *u);
STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio_ex(BIO *bio,
STACK_OF(X509_INFO) *sk,
pem_password_cb *cb, void *u,
OSSL_LIB_CTX *libctx,
const char *propq);
STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,
pem_password_cb *cb, void *u);
copy these exactly, bestie, no "fixing" them, they're iconic as-is π
π¦ DESCRIPTION π¦
so here's the tea, function by function:
PEM_X509_INFO_read_ex()β loads theX509_INFOobjects from a filefp. that's it, that's the whole job β¨PEM_X509_INFO_read()β same energy asPEM_X509_INFO_read_ex(), except it uses the default (NULL) library contextlibctxand an empty property querypropq. so like, the plain-vanilla version π¦PEM_X509_INFO_read_bio_ex()β loads theX509_INFOobjects using abiobp.PEM_X509_INFO_read_bio()β same asPEM_X509_INFO_read_bio_ex()but with the default (NULL) library contextlibctxand empty property querypropq. again: vanilla π«Ά
π what's actually inside an X509_INFO?
each of the loaded X509_INFO objects can contain a CRL, a certificate, and/or a private key β like a little trio friendship bracelet π₯
the elements get read sequentially, and as far as they're of a different type than the elements read before them, they get combined into the same X509_INFO object. the idea behind this? say a certificate is followed by a private key β then that private key is supposed to correspond to that certificate. main character + their plus-one energy, fr fr π
π§ the sk stack situation
if the input stack sk is NULL, a new stack is allocated. otherwise, the given stack gets extended. choose your fighter π
π passwords & the cb / u duo
the optional cb and u parameters can be used to provide a pass phrase needed for decrypting encrypted PEM structures (normally only private keys). see PEM_read_bio_PrivateKey(3) and passphrase-encoding(7) for the details β iykyk π
π libctx & propq
the library context libctx and property query propq are used for fetching algorithms from providers. that's their whole job, no cap β
π RETURN VALUES π
PEM_X509_INFO_read_ex(), PEM_X509_INFO_read(), PEM_X509_INFO_read_bio_ex() and PEM_X509_INFO_read_bio() all return a stack of X509_INFO objects β or NULL on failure π (yes, all four, no exceptions, check your returns bestie)
π SEE ALSO π
go read these next, they're the extended universe:
β HISTORY β
the functions PEM_X509_INFO_read_ex() and PEM_X509_INFO_read_bio_ex() were added in OpenSSL 3.0. so if you're on something older, those _ex cuties simply do not exist yet π
π COPYRIGHT π
Copyright 2020-2022 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>.
ngl, "you may not use this file except in compliance with the License" is the serious bit β take it seriously, bestie, it's the actual legal tea π
alright, that's the whole page πΈ huge shoutout to OpenSSL 3.5.6, dated 2026-04-07 β that's the version and date this page shipped with, mwah π slay, go read your PEM files responsibly π¦
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms