OSSL_STORE_EXPECT(3ossl)

✨ OSSL_STORE_EXPECT ✨ (the 3ossl manual moment)

okay bestie, so this is the 3ossl page about the three lil functions β€” OSSL_STORE_expect, OSSL_STORE_supports_search, and OSSL_STORE_find β€” and their whole job is telling a store context what kind of object you're actually looking for. it's giving "manifesting your search results" and honestly? we love that for you πŸ’…


🌸 NAME 🌸

OSSL_STORE_expect, OSSL_STORE_supports_search, OSSL_STORE_find β€” specify what object type is expected πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

#include <openssl/store.h>

int OSSL_STORE_expect(OSSL_STORE_CTX *ctx, int expected_type);

int OSSL_STORE_supports_search(OSSL_STORE_CTX *ctx, int criterion_type);

int OSSL_STORE_find(OSSL_STORE_CTX *ctx, OSSL_STORE_SEARCH *search);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, OSSL_STORE_expect() is the one that lets your app filter what OSSL_STORE_load() hands back, by telling it a OSSL_STORE_INFO type. by default, no expectations on the types of objects to be loaded are made β€” it's a free-for-all, no thoughts head empty.

expected_type can be 0 to say out loud "yeah no expectation here, we're chill like that", or it can be any of the known object types (peep "SUPPORTED OBJECTS" in OSSL_STORE_INFO(3)) β€” except for OSSL_STORE_INFO_NAME, that one is not invited to this party πŸ™…

for example, if "file:/foo/bar/store.pem" has a whole bunch of objects of different type in it and literally only the certs are interesting to you, your application can just say it expects the type OSSL_STORE_INFO_CERT. slay, narrowed down, no scrolling through irrelevant stuff ✨

OSSL_STORE_find() is here to help your app specify a criterion for a more fine grained search of objects. the detail-oriented queen πŸ‘‘

OSSL_STORE_supports_search() checks if the loader of the given OSSL_STORE context actually supports the given search type. go read "SUPPORTED CRITERION TYPES" in OSSL_STORE_SEARCH(3) for the deets on which search criterion types are supported. vibe check before you commit, yk?

πŸ’€ important one: OSSL_STORE_expect() and OSSL_STORE_find must be called before the first OSSL_STORE_load() of a given session, or they will fail. no cap. call them early or not at all.

🧚 NOTES 🧚

if your application needs a more elaborate filter, the better glow-up is to use a post-processing function instead. see OSSL_STORE_open(3) for more info 🫢

but lowkey β€” some loaders can take advantage of knowing the expected type to make object retrieval more efficient. so if you're expecting a single type, this method is usually preferable. efficiency icon behavior ⭐


πŸ‘‘ RETURN VALUES πŸ‘‘

  • OSSL_STORE_expect() returns 1 on success, or 0 on failure.
  • OSSL_STORE_supports_search() returns 1 if the criterion is supported, or 0 otherwise.
  • OSSL_STORE_find() returns 1 on success, or 0 on failure.

one means we ate, zero means we did not 😭


🌈 SEE ALSO 🌈

ossl_store(7), OSSL_STORE_INFO(3), OSSL_STORE_SEARCH(3), OSSL_STORE_load(3)


πŸ“ HISTORY πŸ“

OSSL_STORE_expect(), OSSL_STORE_supports_search() and OSSL_STORE_find() were added in OpenSSL 1.1.1. vintage but still serving ✨


Copyright 2018-2021 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!! this was the OpenSSL 3.5.9 version, dated 2026-09-29, from the OSSL_STORE_EXPECT(3ossl) manual. mwah, go forth and expect your types early πŸ’…πŸ’–πŸ¦‹

πŸ“¦ where this page comes from