X509_LOOKUP(3ossl)
π X509_LOOKUP π
okay bestie, welcome to the OpenSSL 3ossl manual page for X509_LOOKUP β the certificate lookup mechanism page, and she is literally the main character of finding certs and CRLs. π
β¨ NAME β¨
This page is your group chat for the whole squad: X509_LOOKUP, X509_LOOKUP_TYPE, X509_LOOKUP_new, X509_LOOKUP_free, X509_LOOKUP_init, X509_LOOKUP_shutdown, X509_LOOKUP_set_method_data, X509_LOOKUP_get_method_data, X509_LOOKUP_ctrl_ex, X509_LOOKUP_ctrl, X509_LOOKUP_load_file_ex, X509_LOOKUP_load_file, X509_LOOKUP_add_dir, X509_LOOKUP_add_store_ex, X509_LOOKUP_add_store, X509_LOOKUP_load_store_ex, X509_LOOKUP_load_store, X509_LOOKUP_get_store, X509_LOOKUP_by_subject_ex, X509_LOOKUP_by_subject, X509_LOOKUP_by_issuer_serial, X509_LOOKUP_by_fingerprint, and X509_LOOKUP_by_alias β all of it: OpenSSL certificate lookup mechanisms. π
πΈ SYNOPSIS πΈ
#include <openssl/x509_vfy.h>
typedef x509_lookup_st X509_LOOKUP;
typedef enum X509_LOOKUP_TYPE;
X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);
int X509_LOOKUP_init(X509_LOOKUP *ctx);
int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
void X509_LOOKUP_free(X509_LOOKUP *ctx);
int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data);
void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx);
int X509_LOOKUP_ctrl_ex(X509_LOOKUP *ctx, int cmd, const char *argc, long argl,
char **ret, OSSL_LIB_CTX *libctx, const char *propq);
int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
long argl, char **ret);
int X509_LOOKUP_load_file_ex(X509_LOOKUP *ctx, char *name, long type,
OSSL_LIB_CTX *libctx, const char *propq);
int X509_LOOKUP_load_file(X509_LOOKUP *ctx, char *name, long type);
int X509_LOOKUP_load_file_ex(X509_LOOKUP *ctx, char *name, long type,
OSSL_LIB_CTX *libctx, const char *propq);
int X509_LOOKUP_add_dir(X509_LOOKUP *ctx, char *name, long type);
int X509_LOOKUP_add_store_ex(X509_LOOKUP *ctx, char *uri, OSSL_LIB_CTX *libctx,
const char *propq);
int X509_LOOKUP_add_store(X509_LOOKUP *ctx, char *uri);
int X509_LOOKUP_load_store_ex(X509_LOOKUP *ctx, char *uri, OSSL_LIB_CTX *libctx,
const char *propq);
int X509_LOOKUP_load_store(X509_LOOKUP *ctx, char *uri);
X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx);
int X509_LOOKUP_by_subject_ex(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
const X509_NAME *name, X509_OBJECT *ret,
OSSL_LIB_CTX *libctx, const char *propq);
int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
const X509_NAME *name, X509_OBJECT *ret);
int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
const X509_NAME *name,
const ASN1_INTEGER *serial, X509_OBJECT *ret);
int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
const unsigned char *bytes, int len,
X509_OBJECT *ret);
int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
const char *str, int len, X509_OBJECT *ret);
π¦ DESCRIPTION π¦
The X509_LOOKUP structure holds the information needed to look up certificates and CRLs according to an associated X509_LOOKUP_METHOD(3). You can add multiple X509_LOOKUP instances to an X509_STORE(3) to enable lookup in that store. β¨
X509_LOOKUP_new()β creates a newX509_LOOKUPusing the given lookup method. It can also be created by callingX509_STORE_add_lookup(3), which will associate aX509_STOREwith the lookup mechanism.X509_LOOKUP_init()β initializes the internal state and resources as needed by the givenX509_LOOKUPto do its work.X509_LOOKUP_shutdown()β tears down the internal state and resources of the givenX509_LOOKUP.X509_LOOKUP_free()β destructs the givenX509_LOOKUP. If the argument isNULL, nothing is done.X509_LOOKUP_set_method_data()andX509_LOOKUP_get_method_data()β associate and retrieve a pointer to application data to and from the givenX509_LOOKUP, respectively.X509_LOOKUP_ctrl_ex()β is used to set or get additional data to or from anX509_LOOKUPstructure using any control function in the associatedX509_LOOKUP_METHOD(3). The arguments of the control command are passed viaargcandargl, and its return value via*ret. The library contextlibctxand property querypropqare used when fetching algorithms from providers. The meaning of the arguments depends on thecmdnumber of the control command. In general, this function is not called directly, but wrapped by a macro call, see below. The control cmds known to OpenSSL are discussed in more depth in "Control Commands".X509_LOOKUP_ctrl()β is similar toX509_LOOKUP_ctrl_ex()but usesNULLfor the library contextlibctxand property querypropq.X509_LOOKUP_load_file_ex()β passes a filename to be loaded immediately into the associatedX509_STORE. The library contextlibctxand property querypropqare used when fetching algorithms from providers.typeindicates what type of object is expected. This can only be used with a lookup using the implementationX509_LOOKUP_file(3).X509_LOOKUP_load_file()β is similar toX509_LOOKUP_load_file_ex()but usesNULLfor the library contextlibctxand property querypropq.X509_LOOKUP_add_dir()β passes a directory specification from which certificates and CRLs are loaded on demand into the associatedX509_STORE.typeindicates what type of object is expected. This can only be used with a lookup using the implementationX509_LOOKUP_hash_dir(3).X509_LOOKUP_add_store_ex()β passes a URI for a directory-like structure from which containers with certificates and CRLs are loaded on demand into the associatedX509_STORE. The library contextlibctxand property querypropqare used when fetching algorithms from providers.X509_LOOKUP_add_store()β is similar toX509_LOOKUP_add_store_ex()but usesNULLfor the library contextlibctxand property querypropq.X509_LOOKUP_load_store_ex()β passes a URI for a single container from which certificates and CRLs are immediately loaded into the associatedX509_STORE. The library contextlibctxand property querypropqare used when fetching algorithms from providers. These functions can only be used with a lookup using the implementationX509_LOOKUP_store(3).X509_LOOKUP_load_store()β is similar toX509_LOOKUP_load_store_ex()but usesNULLfor the library contextlibctxand property querypropq.
X509_LOOKUP_load_file_ex(), X509_LOOKUP_load_file(), X509_LOOKUP_add_dir(), X509_LOOKUP_add_store_ex(), X509_LOOKUP_add_store(), X509_LOOKUP_load_store_ex() and X509_LOOKUP_load_store() are implemented as macros that use X509_LOOKUP_ctrl().
X509_LOOKUP_by_subject_ex(), X509_LOOKUP_by_subject(), X509_LOOKUP_by_issuer_serial(), X509_LOOKUP_by_fingerprint(), and X509_LOOKUP_by_alias() look up certificates and CRLs in the X509_STORE(3) associated with the X509_LOOKUP using different criteria, where the looked up object is stored in ret. Some of the underlying X509_LOOKUP_METHODs will also cache objects matching the criteria in the associated X509_STORE, which makes it possible to handle cases where the criteria have more than one hit.
π₯ Control Commands π₯
The X509_LOOKUP_METHODs built into OpenSSL recognize the following X509_LOOKUP_ctrl() cmds:
X509_L_FILE_LOADβ this is the command thatX509_LOOKUP_load_file_ex()andX509_LOOKUP_load_file()use. The filename is passed inargc, and thetypeinargl.X509_L_ADD_DIRβ this is the command thatX509_LOOKUP_add_dir()uses. The directory specification is passed inargc, and thetypeinargl.X509_L_ADD_STOREβ this is the command thatX509_LOOKUP_add_store_ex()andX509_LOOKUP_add_store()use. The URI is passed inargc.X509_L_LOAD_STOREβ this is the command thatX509_LOOKUP_load_store_ex()andX509_LOOKUP_load_store()use. The URI is passed inargc.
π RETURN VALUES π
X509_LOOKUP_new()β returns aX509_LOOKUPpointer when successful, orNULLon error.X509_LOOKUP_init()andX509_LOOKUP_shutdown()β return1on success, or0on error.X509_LOOKUP_ctrl_ex()andX509_LOOKUP_ctrl()β return-1if theX509_LOOKUPdoesn't have an associatedX509_LOOKUP_METHOD, or1if the method doesn't have a control function. Otherwise, it returns what the control function in theX509_LOOKUP_METHODreturns, which is usually1on success and0on error but could also be-1on failure.X509_LOOKUP_get_store()β returns aX509_STOREpointer if there is one, otherwiseNULL.X509_LOOKUP_by_subject_ex()β returns0if there is noX509_LOOKUP_METHODthat implements any of theget_by_subject_ex()orget_by_subject()functions. It callsget_by_subject_ex()if present, otherwiseget_by_subject(), and returns the result of the function, which is usually1on success and0on error.X509_LOOKUP_by_subject()β is similar toX509_LOOKUP_by_subject_ex()but passesNULLfor both thelibctxandpropq.X509_LOOKUP_by_issuer_serial(),X509_LOOKUP_by_fingerprint(), andX509_LOOKUP_by_alias()β all return0if there is noX509_LOOKUP_METHODor that method doesn't implement the corresponding function. Otherwise, they return what the corresponding function in theX509_LOOKUP_METHODreturns, which is usually1on success and0in error.
π SEE ALSO π
β HISTORY β
- The functions
X509_LOOKUP_by_subject_ex()andX509_LOOKUP_ctrl_ex()were added in OpenSSL 3.0. - The macros
X509_LOOKUP_load_file_ex(),X509_LOOKUP_load_store_ex()and509_LOOKUP_add_store_ex()were added in OpenSSL 3.0. (yes, the page really says509_LOOKUP_add_store_ex()β iconic typo behavior ππ )
π COPYRIGHT π
Copyright 2020-2024 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>.
mwah π this page is from OpenSSL 3.5.0, dated 2026-09-25 β and it's the X509_LOOKUP(3ossl) manual page. bye bestie, go find those certs π«Ά
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms