X509_STORE_LOAD_MEM(3ssl)

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

πŸŽ€ NAME πŸŽ€

Welcome to the X509_STORE_LOAD_LOCATION(3) page from the Library Functions Manual, bestie πŸ’–. The main characters are X509_STORE_load_locations, X509_STORE_set_default_paths, X509_STORE_load_mem, and X509_STORE_add_lookup β€” configure files and directories used by a certificate store. Periodt.

✨ SYNOPSIS ✨

#include <openssl/x509_vfy.h>

int
X509_STORE_load_locations(X509_STORE *store, const char *file,
    const char *dirs);

int
X509_STORE_set_default_paths(X509_STORE *store);

int
X509_STORE_load_mem(X509_STORE *store, void *buffer, int length);

X509_LOOKUP *
X509_STORE_add_lookup(X509_STORE *store,
    const X509_LOOKUP_METHOD *method);

🌸 DESCRIPTION 🌸

Okay so here’s the vibe check on each function πŸ‘‘:

  • X509_STORE_load_locations() β€” tells the store to use the PEM file and all the PEM files in the directories contained in the colon-separated list dirs for looking up certificates, in addition to files and directories that are already configured. The certificates in the directories must be in hashed form, as documented in X509_LOOKUP_hash_dir(3). Directories already in use are not added again. If NULL is passed for file or dirs, no new file or no new directories are added, respectively. No cap.
  • X509_STORE_load_locations() is identical to SSL_CTX_load_verify_locations(3) except that it operates directly on an X509_STORE object, rather than on the store used by an SSL context. See that manual page for more information.
  • X509_STORE_set_default_paths() β€” similar, except it tells the store to use the default PEM file and directory (as documented in β€œFILES”) in addition to what is already configured. It ignores errors that occur while trying to load the file or to add the directory, but it may still fail for other reasons, for example when out of memory while trying to allocate the required X509_LOOKUP objects.
  • X509_STORE_set_default_paths() is identical to SSL_CTX_set_default_verify_paths(3) except that it operates directly on an X509_STORE object, rather than on the store used by an SSL context. See that manual page for more information.

The above functions are wrappers around X509_LOOKUP_load_file(3) and X509_LOOKUP_add_dir(3). Slay.

  • X509_STORE_load_mem() β€” tells the store to use the certificates contained in the memory buffer of the given length for certificate lookup. It is a wrapper around X509_LOOKUP_add_mem(3). Memory-buffer realness πŸ’….
  • X509_STORE_add_lookup() β€” checks whether the store already contains an X509_LOOKUP object using the given method; if it does, the existing object is returned and no other action occurs. Otherwise, a new X509_LOOKUP object is allocated, added, and returned. This function is used internally by all the functions listed above.

πŸ”₯ RETURN VALUES πŸ”₯

  • X509_STORE_load_locations() β€” returns 1 if all files and directories specified were successfully added. It returns 0 for failure. That can happen if adding the file failed, if adding any of the directories failed, or if both arguments were NULL.
  • X509_STORE_set_default_paths() β€” returns 0 for some error conditions and 1 otherwise, not just for success, but also for various cases of failure. Iykyk.
  • X509_STORE_load_mem() β€” returns 1 for success or 0 for failure. In particular, parse errors or lack of memory can cause failure.
  • X509_STORE_add_lookup() β€” returns the existing or new lookup object or NULL on failure. This is an internal pointer that must not be freed. With LibreSSL, the only reason for failure is lack of memory.

πŸ¦‹ FILES πŸ¦‹

  • /etc/ssl/cert.pem β€” default PEM file for X509_STORE_set_default_paths()
  • /etc/ssl/certs/ β€” default directory for X509_STORE_set_default_paths()

🌈 SEE ALSO 🌈

⭐ HISTORY ⭐

  • X509_STORE_load_locations(), X509_STORE_set_default_paths(), and X509_STORE_add_lookup() first appeared in SSLeay 0.8.0 and have been available since OpenBSD 2.4.
  • X509_STORE_load_mem() first appeared in OpenBSD 5.7.

πŸ’€ BUGS πŸ’€

Bestie, warning: by the time that adding a directory is found to have failed, the file and some other directories may already have been successfully loaded, so these functions may change the state of the store even when they fail. Not the clean rollback fantasy 😭.
Also: X509_STORE_set_default_paths() clears the error queue, deleting even error information that was already present when it was called. That’s giving chaotic cleanup energy, fr fr.

This page is Debian-flavored, dated September 2, 2024 β€” that’s the cute lil source/version + date sign-off, bestie πŸ’–βœ¨

πŸ“¦ where this page comes from