PEM_X509_INFO_READ_BIO_EX(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’– PEM_X509_INFO_READ_BIO_EX(3ossl) πŸ’–

okay so bestie, welcome to the <openssl/pem.h> chapter of your life β€” this is the family of functions that slurps PEM-encoded stuff out of a file or a BIO and hands you back a whole stack of X509_INFO objects. yes, that X509_INFO. the glow-up container. let's get into it ✨


🌸 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 πŸŽ€


πŸ¦‹ 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);

πŸ’œ DESCRIPTION πŸ’œ

  • PEM_X509_INFO_read_ex() β€” loads the X509_INFO objects out of a file, fp. file girlies rise πŸ’…
  • PEM_X509_INFO_read() β€” literally the same vibe as PEM_X509_INFO_read_ex(), except it rolls with the default (NULL) library context libctx and an empty property query propq. the no-frills edition.
  • PEM_X509_INFO_read_bio_ex() β€” loads the X509_INFO objects using a bio (that's the BIO *bio in the synopsis, bestie, keep up 🫢).
  • PEM_X509_INFO_read_bio() β€” same energy as PEM_X509_INFO_read_bio_ex(), but again with the default (NULL) library context libctx and empty property query propq.

πŸŽ€ so what's actually in an X509_INFO?

Each of the loaded X509_INFO objects can hold a CRL, a certificate, and/or a private key β€” like, all the things πŸ”₯

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 is that if, for instance, a certificate is followed by a private key, the private key is supposed to correspond to the certificate. it's giving soulmate matching ngl πŸ’–

🧚 the input stack sk

If the input stack sk is NULL, a new stack gets allocated. otherwise? the given stack is extended. either way you eat 🌈

πŸ” the password callback: cb and u

The optional cb and u parameters can be used for providing 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 deets, iykyk.

πŸ‘‘ the fancy provider bits: libctx and propq

The library context libctx and property query propq are used for fetching algorithms from providers. very main character energy of them.


⭐ RETURN VALUES ⭐

PEM_X509_INFO_read_ex(), PEM_X509_INFO_read(), PEM_X509_INFO_read_bio_ex() and PEM_X509_INFO_read_bio() return a stack of X509_INFO objects β€” or NULL on failure 😭

fr fr, always check for that NULL. do not be out here dereferencing a failed read, bestie. that's not the slay you think it is πŸ’€

πŸ“ SEE ALSO πŸ“


🌸 HISTORY 🌸

The functions PEM_X509_INFO_read_ex() and PEM_X509_INFO_read_bio_ex() were added in OpenSSL 3.0. the OGs remember before that πŸ’…


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>.


πŸ¦‹ that's the whole page, bestie! go read some PEM files responsibly ✨

OpenSSL 3.5.0 Β· 2026-09-25 Β· mwah πŸ’‹ thanks for reading, you ate πŸŽ€

πŸ“¦ where this page comes from