Home | History | Annotate | Line # | Download | only in man3
      1      1.1  christos =pod
      2      1.1  christos 
      3      1.1  christos =head1 NAME
      4      1.1  christos 
      5      1.1  christos X509_LOOKUP, X509_LOOKUP_TYPE,
      6      1.1  christos X509_LOOKUP_new, X509_LOOKUP_free, X509_LOOKUP_init,
      7      1.1  christos X509_LOOKUP_shutdown,
      8      1.1  christos X509_LOOKUP_set_method_data, X509_LOOKUP_get_method_data,
      9  1.1.1.2  christos X509_LOOKUP_ctrl_ex, X509_LOOKUP_ctrl,
     10  1.1.1.2  christos X509_LOOKUP_load_file_ex, X509_LOOKUP_load_file,
     11  1.1.1.2  christos X509_LOOKUP_add_dir,
     12  1.1.1.2  christos X509_LOOKUP_add_store_ex, X509_LOOKUP_add_store,
     13  1.1.1.2  christos X509_LOOKUP_load_store_ex, X509_LOOKUP_load_store,
     14  1.1.1.2  christos X509_LOOKUP_get_store,
     15  1.1.1.2  christos X509_LOOKUP_by_subject_ex, X509_LOOKUP_by_subject,
     16      1.1  christos X509_LOOKUP_by_issuer_serial, X509_LOOKUP_by_fingerprint,
     17      1.1  christos X509_LOOKUP_by_alias
     18      1.1  christos - OpenSSL certificate lookup mechanisms
     19      1.1  christos 
     20      1.1  christos =head1 SYNOPSIS
     21      1.1  christos 
     22      1.1  christos  #include <openssl/x509_vfy.h>
     23      1.1  christos 
     24      1.1  christos  typedef x509_lookup_st X509_LOOKUP;
     25      1.1  christos 
     26      1.1  christos  typedef enum X509_LOOKUP_TYPE;
     27      1.1  christos 
     28      1.1  christos  X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);
     29      1.1  christos  int X509_LOOKUP_init(X509_LOOKUP *ctx);
     30      1.1  christos  int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
     31      1.1  christos  void X509_LOOKUP_free(X509_LOOKUP *ctx);
     32      1.1  christos 
     33      1.1  christos  int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data);
     34      1.1  christos  void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx);
     35      1.1  christos 
     36  1.1.1.2  christos  int X509_LOOKUP_ctrl_ex(X509_LOOKUP *ctx, int cmd, const char *argc, long argl,
     37  1.1.1.2  christos                          char **ret, OSSL_LIB_CTX *libctx, const char *propq);
     38      1.1  christos  int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
     39      1.1  christos                       long argl, char **ret);
     40  1.1.1.2  christos  int X509_LOOKUP_load_file_ex(X509_LOOKUP *ctx, char *name, long type,
     41  1.1.1.2  christos                               OSSL_LIB_CTX *libctx, const char *propq);
     42      1.1  christos  int X509_LOOKUP_load_file(X509_LOOKUP *ctx, char *name, long type);
     43  1.1.1.2  christos  int X509_LOOKUP_load_file_ex(X509_LOOKUP *ctx, char *name, long type,
     44  1.1.1.2  christos                               OSSL_LIB_CTX *libctx, const char *propq);
     45      1.1  christos  int X509_LOOKUP_add_dir(X509_LOOKUP *ctx, char *name, long type);
     46  1.1.1.2  christos  int X509_LOOKUP_add_store_ex(X509_LOOKUP *ctx, char *uri, OSSL_LIB_CTX *libctx,
     47  1.1.1.2  christos                               const char *propq);
     48  1.1.1.2  christos  int X509_LOOKUP_add_store(X509_LOOKUP *ctx, char *uri);
     49  1.1.1.2  christos  int X509_LOOKUP_load_store_ex(X509_LOOKUP *ctx, char *uri, OSSL_LIB_CTX *libctx,
     50  1.1.1.2  christos                                const char *propq);
     51  1.1.1.2  christos  int X509_LOOKUP_load_store(X509_LOOKUP *ctx, char *uri);
     52      1.1  christos 
     53      1.1  christos  X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx);
     54      1.1  christos 
     55  1.1.1.2  christos  int X509_LOOKUP_by_subject_ex(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
     56  1.1.1.2  christos                                const X509_NAME *name, X509_OBJECT *ret,
     57  1.1.1.2  christos                                OSSL_LIB_CTX *libctx, const char *propq);
     58      1.1  christos  int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
     59  1.1.1.2  christos                             const X509_NAME *name, X509_OBJECT *ret);
     60      1.1  christos  int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
     61  1.1.1.2  christos                                   const X509_NAME *name,
     62  1.1.1.2  christos                                   const ASN1_INTEGER *serial, X509_OBJECT *ret);
     63      1.1  christos  int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
     64      1.1  christos                                 const unsigned char *bytes, int len,
     65      1.1  christos                                 X509_OBJECT *ret);
     66      1.1  christos  int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
     67      1.1  christos                           const char *str, int len, X509_OBJECT *ret);
     68      1.1  christos 
     69      1.1  christos =head1 DESCRIPTION
     70      1.1  christos 
     71      1.1  christos The B<X509_LOOKUP> structure holds the information needed to look up
     72      1.1  christos certificates and CRLs according to an associated L<X509_LOOKUP_METHOD(3)>.
     73      1.1  christos Multiple B<X509_LOOKUP> instances can be added to an L<X509_STORE(3)>
     74      1.1  christos to enable lookup in that store.
     75      1.1  christos 
     76      1.1  christos X509_LOOKUP_new() creates a new B<X509_LOOKUP> using the given lookup
     77      1.1  christos I<method>.
     78      1.1  christos It can also be created by calling L<X509_STORE_add_lookup(3)>, which
     79  1.1.1.2  christos will associate a B<X509_STORE> with the lookup mechanism.
     80      1.1  christos 
     81      1.1  christos X509_LOOKUP_init() initializes the internal state and resources as
     82      1.1  christos needed by the given B<X509_LOOKUP> to do its work.
     83      1.1  christos 
     84      1.1  christos X509_LOOKUP_shutdown() tears down the internal state and resources of
     85      1.1  christos the given B<X509_LOOKUP>.
     86      1.1  christos 
     87      1.1  christos X509_LOOKUP_free() destructs the given B<X509_LOOKUP>.
     88  1.1.1.3  christos If the argument is NULL, nothing is done.
     89      1.1  christos 
     90  1.1.1.2  christos X509_LOOKUP_set_method_data() and X509_LOOKUP_get_method_data()
     91  1.1.1.2  christos associates and retrieves a pointer to application data to and from the
     92  1.1.1.2  christos given B<X509_LOOKUP>, respectively.
     93      1.1  christos 
     94  1.1.1.2  christos X509_LOOKUP_ctrl_ex() is used to set or get additional data to or from
     95  1.1.1.2  christos a B<X509_LOOKUP> structure or its associated L<X509_LOOKUP_METHOD(3)>.
     96      1.1  christos The arguments of the control command are passed via I<argc> and I<argl>,
     97  1.1.1.2  christos its return value via I<*ret>. The library context I<libctx> and property
     98  1.1.1.2  christos query I<propq> are used when fetching algorithms from providers.
     99      1.1  christos The meaning of the arguments depends on the I<cmd> number of the
    100      1.1  christos control command. In general, this function is not called directly, but
    101      1.1  christos wrapped by a macro call, see below.
    102      1.1  christos The control I<cmd>s known to OpenSSL are discussed in more depth
    103      1.1  christos in L</Control Commands>.
    104      1.1  christos 
    105  1.1.1.2  christos X509_LOOKUP_ctrl() is similar to X509_LOOKUP_ctrl_ex() but
    106  1.1.1.2  christos uses NULL for the library context I<libctx> and property query I<propq>.
    107  1.1.1.2  christos 
    108  1.1.1.2  christos X509_LOOKUP_load_file_ex() passes a filename to be loaded immediately
    109  1.1.1.2  christos into the associated B<X509_STORE>. The library context I<libctx> and property
    110  1.1.1.2  christos query I<propq> are used when fetching algorithms from providers.
    111      1.1  christos I<type> indicates what type of object is expected.
    112      1.1  christos This can only be used with a lookup using the implementation
    113      1.1  christos L<X509_LOOKUP_file(3)>.
    114      1.1  christos 
    115  1.1.1.2  christos X509_LOOKUP_load_file() is similar to X509_LOOKUP_load_file_ex() but
    116  1.1.1.2  christos uses NULL for the library context I<libctx> and property query I<propq>.
    117  1.1.1.2  christos 
    118      1.1  christos X509_LOOKUP_add_dir() passes a directory specification from which
    119      1.1  christos certificates and CRLs are loaded on demand into the associated
    120      1.1  christos B<X509_STORE>.
    121      1.1  christos I<type> indicates what type of object is expected.
    122      1.1  christos This can only be used with a lookup using the implementation
    123      1.1  christos L<X509_LOOKUP_hash_dir(3)>.
    124      1.1  christos 
    125  1.1.1.2  christos X509_LOOKUP_add_store_ex() passes a URI for a directory-like structure
    126  1.1.1.2  christos from which containers with certificates and CRLs are loaded on demand
    127  1.1.1.2  christos into the associated B<X509_STORE>. The library context I<libctx> and property
    128  1.1.1.2  christos query I<propq> are used when fetching algorithms from providers.
    129  1.1.1.2  christos 
    130  1.1.1.2  christos X509_LOOKUP_add_store() is similar to X509_LOOKUP_add_store_ex() but
    131  1.1.1.2  christos uses NULL for the library context I<libctx> and property query I<propq>.
    132  1.1.1.2  christos 
    133  1.1.1.2  christos X509_LOOKUP_load_store_ex() passes a URI for a single container from
    134  1.1.1.2  christos which certificates and CRLs are immediately loaded into the associated
    135  1.1.1.2  christos B<X509_STORE>. The library context I<libctx> and property query I<propq> are used
    136  1.1.1.2  christos when fetching algorithms from providers.
    137  1.1.1.2  christos These functions can only be used with a lookup using the
    138  1.1.1.2  christos implementation L<X509_LOOKUP_store(3)>.
    139  1.1.1.2  christos 
    140  1.1.1.2  christos X509_LOOKUP_load_store() is similar to X509_LOOKUP_load_store_ex() but
    141  1.1.1.2  christos uses NULL for the library context I<libctx> and property query I<propq>.
    142  1.1.1.2  christos 
    143  1.1.1.2  christos X509_LOOKUP_load_file_ex(), X509_LOOKUP_load_file(),
    144  1.1.1.2  christos X509_LOOKUP_add_dir(),
    145  1.1.1.2  christos X509_LOOKUP_add_store_ex() X509_LOOKUP_add_store(),
    146  1.1.1.2  christos X509_LOOKUP_load_store_ex() and X509_LOOKUP_load_store() are
    147  1.1.1.2  christos implemented as macros that use X509_LOOKUP_ctrl().
    148  1.1.1.2  christos 
    149  1.1.1.2  christos X509_LOOKUP_by_subject_ex(), X509_LOOKUP_by_subject(),
    150  1.1.1.2  christos X509_LOOKUP_by_issuer_serial(), X509_LOOKUP_by_fingerprint(), and
    151  1.1.1.2  christos X509_LOOKUP_by_alias() look up certificates and CRLs in the L<X509_STORE(3)>
    152  1.1.1.2  christos associated with the B<X509_LOOKUP> using different criteria, where the looked up
    153  1.1.1.2  christos object is stored in I<ret>.
    154      1.1  christos Some of the underlying B<X509_LOOKUP_METHOD>s will also cache objects
    155      1.1  christos matching the criteria in the associated B<X509_STORE>, which makes it
    156      1.1  christos possible to handle cases where the criteria have more than one hit.
    157      1.1  christos 
    158      1.1  christos =head2 Control Commands
    159      1.1  christos 
    160  1.1.1.2  christos The B<X509_LOOKUP_METHOD>s built into OpenSSL recognize the following
    161      1.1  christos X509_LOOKUP_ctrl() I<cmd>s:
    162      1.1  christos 
    163      1.1  christos =over 4
    164      1.1  christos 
    165      1.1  christos =item B<X509_L_FILE_LOAD>
    166      1.1  christos 
    167  1.1.1.2  christos This is the command that X509_LOOKUP_load_file_ex() and
    168  1.1.1.2  christos X509_LOOKUP_load_file() use.
    169      1.1  christos The filename is passed in I<argc>, and the type in I<argl>.
    170      1.1  christos 
    171      1.1  christos =item B<X509_L_ADD_DIR>
    172      1.1  christos 
    173      1.1  christos This is the command that X509_LOOKUP_add_dir() uses.
    174      1.1  christos The directory specification is passed in I<argc>, and the type in
    175      1.1  christos I<argl>.
    176      1.1  christos 
    177      1.1  christos =item B<X509_L_ADD_STORE>
    178      1.1  christos 
    179  1.1.1.2  christos This is the command that X509_LOOKUP_add_store_ex() and
    180  1.1.1.2  christos X509_LOOKUP_add_store() use.
    181      1.1  christos The URI is passed in I<argc>.
    182      1.1  christos 
    183      1.1  christos =item B<X509_L_LOAD_STORE>
    184      1.1  christos 
    185  1.1.1.2  christos This is the command that X509_LOOKUP_load_store_ex() and
    186  1.1.1.2  christos X509_LOOKUP_load_store() use.
    187      1.1  christos The URI is passed in I<argc>.
    188      1.1  christos 
    189      1.1  christos =back
    190      1.1  christos 
    191      1.1  christos =head1 RETURN VALUES
    192      1.1  christos 
    193  1.1.1.2  christos X509_LOOKUP_new() returns a B<X509_LOOKUP> pointer when successful,
    194      1.1  christos or NULL on error.
    195      1.1  christos 
    196      1.1  christos X509_LOOKUP_init() and X509_LOOKUP_shutdown() return 1 on success, or
    197      1.1  christos 0 on error.
    198      1.1  christos 
    199      1.1  christos X509_LOOKUP_ctrl() returns -1 if the B<X509_LOOKUP> doesn't have an
    200      1.1  christos associated B<X509_LOOKUP_METHOD>, or 1 if the X<509_LOOKUP_METHOD>
    201      1.1  christos doesn't have a control function.
    202      1.1  christos Otherwise, it returns what the control function in the
    203      1.1  christos B<X509_LOOKUP_METHOD> returns, which is usually 1 on success and 0 in
    204      1.1  christos error.
    205      1.1  christos 
    206  1.1.1.2  christos X509_LOOKUP_get_store() returns a B<X509_STORE> pointer if there is
    207      1.1  christos one, otherwise NULL.
    208      1.1  christos 
    209  1.1.1.2  christos X509_LOOKUP_by_subject_ex(), X509_LOOKUP_by_subject(),
    210  1.1.1.2  christos X509_LOOKUP_by_issuer_serial(), X509_LOOKUP_by_fingerprint(), and
    211  1.1.1.2  christos X509_LOOKUP_by_alias() all return 0 if there is no B<X509_LOOKUP_METHOD> or that
    212  1.1.1.2  christos method doesn't implement the corresponding function.
    213      1.1  christos Otherwise, it returns what the corresponding function in the
    214      1.1  christos B<X509_LOOKUP_METHOD> returns, which is usually 1 on success and 0 in
    215      1.1  christos error.
    216      1.1  christos 
    217      1.1  christos =head1 SEE ALSO
    218      1.1  christos 
    219      1.1  christos L<X509_LOOKUP_METHOD(3)>, L<X509_STORE(3)>
    220      1.1  christos 
    221  1.1.1.2  christos =head1 HISTORY
    222  1.1.1.2  christos 
    223  1.1.1.2  christos The functions X509_LOOKUP_by_subject_ex() and
    224  1.1.1.2  christos X509_LOOKUP_ctrl_ex() were added in OpenSSL 3.0.
    225  1.1.1.2  christos 
    226  1.1.1.2  christos The macros X509_LOOKUP_load_file_ex(),
    227  1.1.1.2  christos X509_LOOKUP_load_store_ex() and 509_LOOKUP_add_store_ex() were
    228  1.1.1.2  christos added in OpenSSL 3.0.
    229  1.1.1.2  christos 
    230      1.1  christos =head1 COPYRIGHT
    231      1.1  christos 
    232  1.1.1.3  christos Copyright 2020-2024 The OpenSSL Project Authors. All Rights Reserved.
    233      1.1  christos 
    234      1.1  christos Licensed under the Apache License 2.0 (the "License").  You may not use
    235      1.1  christos this file except in compliance with the License.  You can obtain a copy
    236      1.1  christos in the file LICENSE in the source distribution or at
    237      1.1  christos L<https://www.openssl.org/source/license.html>.
    238      1.1  christos 
    239      1.1  christos =cut
    240