117f01e99SJung-uk Kim=pod 217f01e99SJung-uk Kim 317f01e99SJung-uk Kim=head1 NAME 417f01e99SJung-uk Kim 517f01e99SJung-uk KimX509_LOOKUP, X509_LOOKUP_TYPE, 617f01e99SJung-uk KimX509_LOOKUP_new, X509_LOOKUP_free, X509_LOOKUP_init, 717f01e99SJung-uk KimX509_LOOKUP_shutdown, 817f01e99SJung-uk KimX509_LOOKUP_set_method_data, X509_LOOKUP_get_method_data, 9b077aed3SPierre ProncheryX509_LOOKUP_ctrl_ex, X509_LOOKUP_ctrl, 10b077aed3SPierre ProncheryX509_LOOKUP_load_file_ex, X509_LOOKUP_load_file, 11b077aed3SPierre ProncheryX509_LOOKUP_add_dir, 12b077aed3SPierre ProncheryX509_LOOKUP_add_store_ex, X509_LOOKUP_add_store, 13b077aed3SPierre ProncheryX509_LOOKUP_load_store_ex, X509_LOOKUP_load_store, 14b077aed3SPierre ProncheryX509_LOOKUP_get_store, 15b077aed3SPierre ProncheryX509_LOOKUP_by_subject_ex, X509_LOOKUP_by_subject, 1617f01e99SJung-uk KimX509_LOOKUP_by_issuer_serial, X509_LOOKUP_by_fingerprint, 1717f01e99SJung-uk KimX509_LOOKUP_by_alias 1817f01e99SJung-uk Kim- OpenSSL certificate lookup mechanisms 1917f01e99SJung-uk Kim 2017f01e99SJung-uk Kim=head1 SYNOPSIS 2117f01e99SJung-uk Kim 2217f01e99SJung-uk Kim #include <openssl/x509_vfy.h> 2317f01e99SJung-uk Kim 2417f01e99SJung-uk Kim typedef x509_lookup_st X509_LOOKUP; 2517f01e99SJung-uk Kim 2617f01e99SJung-uk Kim typedef enum X509_LOOKUP_TYPE; 2717f01e99SJung-uk Kim 2817f01e99SJung-uk Kim X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method); 2917f01e99SJung-uk Kim int X509_LOOKUP_init(X509_LOOKUP *ctx); 3017f01e99SJung-uk Kim int X509_LOOKUP_shutdown(X509_LOOKUP *ctx); 3117f01e99SJung-uk Kim void X509_LOOKUP_free(X509_LOOKUP *ctx); 3217f01e99SJung-uk Kim 3317f01e99SJung-uk Kim int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data); 3417f01e99SJung-uk Kim void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx); 3517f01e99SJung-uk Kim 36b077aed3SPierre Pronchery int X509_LOOKUP_ctrl_ex(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, 37b077aed3SPierre Pronchery char **ret, OSSL_LIB_CTX *libctx, const char *propq); 3817f01e99SJung-uk Kim int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, 3917f01e99SJung-uk Kim long argl, char **ret); 40b077aed3SPierre Pronchery int X509_LOOKUP_load_file_ex(X509_LOOKUP *ctx, char *name, long type, 41b077aed3SPierre Pronchery OSSL_LIB_CTX *libctx, const char *propq); 4217f01e99SJung-uk Kim int X509_LOOKUP_load_file(X509_LOOKUP *ctx, char *name, long type); 43b077aed3SPierre Pronchery int X509_LOOKUP_load_file_ex(X509_LOOKUP *ctx, char *name, long type, 44b077aed3SPierre Pronchery OSSL_LIB_CTX *libctx, const char *propq); 4517f01e99SJung-uk Kim int X509_LOOKUP_add_dir(X509_LOOKUP *ctx, char *name, long type); 46b077aed3SPierre Pronchery int X509_LOOKUP_add_store_ex(X509_LOOKUP *ctx, char *uri, OSSL_LIB_CTX *libctx, 47b077aed3SPierre Pronchery const char *propq); 48b077aed3SPierre Pronchery int X509_LOOKUP_add_store(X509_LOOKUP *ctx, char *uri); 49b077aed3SPierre Pronchery int X509_LOOKUP_load_store_ex(X509_LOOKUP *ctx, char *uri, OSSL_LIB_CTX *libctx, 50b077aed3SPierre Pronchery const char *propq); 51b077aed3SPierre Pronchery int X509_LOOKUP_load_store(X509_LOOKUP *ctx, char *uri); 5217f01e99SJung-uk Kim 5317f01e99SJung-uk Kim X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx); 5417f01e99SJung-uk Kim 55b077aed3SPierre Pronchery int X509_LOOKUP_by_subject_ex(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, 56b077aed3SPierre Pronchery const X509_NAME *name, X509_OBJECT *ret, 57b077aed3SPierre Pronchery OSSL_LIB_CTX *libctx, const char *propq); 5817f01e99SJung-uk Kim int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, 59b077aed3SPierre Pronchery const X509_NAME *name, X509_OBJECT *ret); 6017f01e99SJung-uk Kim int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, 61b077aed3SPierre Pronchery const X509_NAME *name, 62b077aed3SPierre Pronchery const ASN1_INTEGER *serial, X509_OBJECT *ret); 6317f01e99SJung-uk Kim int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, 6417f01e99SJung-uk Kim const unsigned char *bytes, int len, 6517f01e99SJung-uk Kim X509_OBJECT *ret); 6617f01e99SJung-uk Kim int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, 6717f01e99SJung-uk Kim const char *str, int len, X509_OBJECT *ret); 6817f01e99SJung-uk Kim 6917f01e99SJung-uk Kim=head1 DESCRIPTION 7017f01e99SJung-uk Kim 7117f01e99SJung-uk KimThe B<X509_LOOKUP> structure holds the information needed to look up 7217f01e99SJung-uk Kimcertificates and CRLs according to an associated L<X509_LOOKUP_METHOD(3)>. 7317f01e99SJung-uk KimMultiple B<X509_LOOKUP> instances can be added to an L<X509_STORE(3)> 7417f01e99SJung-uk Kimto enable lookup in that store. 7517f01e99SJung-uk Kim 7617f01e99SJung-uk KimX509_LOOKUP_new() creates a new B<X509_LOOKUP> using the given lookup 7717f01e99SJung-uk KimI<method>. 7817f01e99SJung-uk KimIt can also be created by calling L<X509_STORE_add_lookup(3)>, which 79b077aed3SPierre Proncherywill associate a B<X509_STORE> with the lookup mechanism. 8017f01e99SJung-uk Kim 8117f01e99SJung-uk KimX509_LOOKUP_init() initializes the internal state and resources as 8217f01e99SJung-uk Kimneeded by the given B<X509_LOOKUP> to do its work. 8317f01e99SJung-uk Kim 8417f01e99SJung-uk KimX509_LOOKUP_shutdown() tears down the internal state and resources of 8517f01e99SJung-uk Kimthe given B<X509_LOOKUP>. 8617f01e99SJung-uk Kim 8717f01e99SJung-uk KimX509_LOOKUP_free() destructs the given B<X509_LOOKUP>. 88*a7148ab3SEnji CooperIf the argument is NULL, nothing is done. 8917f01e99SJung-uk Kim 90b077aed3SPierre ProncheryX509_LOOKUP_set_method_data() and X509_LOOKUP_get_method_data() 91b077aed3SPierre Proncheryassociates and retrieves a pointer to application data to and from the 92b077aed3SPierre Proncherygiven B<X509_LOOKUP>, respectively. 9317f01e99SJung-uk Kim 94b077aed3SPierre ProncheryX509_LOOKUP_ctrl_ex() is used to set or get additional data to or from 95b077aed3SPierre Proncherya B<X509_LOOKUP> structure or its associated L<X509_LOOKUP_METHOD(3)>. 9617f01e99SJung-uk KimThe arguments of the control command are passed via I<argc> and I<argl>, 97b077aed3SPierre Proncheryits return value via I<*ret>. The library context I<libctx> and property 98b077aed3SPierre Proncheryquery I<propq> are used when fetching algorithms from providers. 9917f01e99SJung-uk KimThe meaning of the arguments depends on the I<cmd> number of the 10017f01e99SJung-uk Kimcontrol command. In general, this function is not called directly, but 10117f01e99SJung-uk Kimwrapped by a macro call, see below. 10217f01e99SJung-uk KimThe control I<cmd>s known to OpenSSL are discussed in more depth 10317f01e99SJung-uk Kimin L</Control Commands>. 10417f01e99SJung-uk Kim 105b077aed3SPierre ProncheryX509_LOOKUP_ctrl() is similar to X509_LOOKUP_ctrl_ex() but 106b077aed3SPierre Proncheryuses NULL for the library context I<libctx> and property query I<propq>. 107b077aed3SPierre Pronchery 108b077aed3SPierre ProncheryX509_LOOKUP_load_file_ex() passes a filename to be loaded immediately 109b077aed3SPierre Proncheryinto the associated B<X509_STORE>. The library context I<libctx> and property 110b077aed3SPierre Proncheryquery I<propq> are used when fetching algorithms from providers. 11117f01e99SJung-uk KimI<type> indicates what type of object is expected. 11217f01e99SJung-uk KimThis can only be used with a lookup using the implementation 11317f01e99SJung-uk KimL<X509_LOOKUP_file(3)>. 11417f01e99SJung-uk Kim 115b077aed3SPierre ProncheryX509_LOOKUP_load_file() is similar to X509_LOOKUP_load_file_ex() but 116b077aed3SPierre Proncheryuses NULL for the library context I<libctx> and property query I<propq>. 117b077aed3SPierre Pronchery 11817f01e99SJung-uk KimX509_LOOKUP_add_dir() passes a directory specification from which 11917f01e99SJung-uk Kimcertificates and CRLs are loaded on demand into the associated 12017f01e99SJung-uk KimB<X509_STORE>. 12117f01e99SJung-uk KimI<type> indicates what type of object is expected. 12217f01e99SJung-uk KimThis can only be used with a lookup using the implementation 12317f01e99SJung-uk KimL<X509_LOOKUP_hash_dir(3)>. 12417f01e99SJung-uk Kim 125b077aed3SPierre ProncheryX509_LOOKUP_add_store_ex() passes a URI for a directory-like structure 126b077aed3SPierre Proncheryfrom which containers with certificates and CRLs are loaded on demand 127b077aed3SPierre Proncheryinto the associated B<X509_STORE>. The library context I<libctx> and property 128b077aed3SPierre Proncheryquery I<propq> are used when fetching algorithms from providers. 12917f01e99SJung-uk Kim 130b077aed3SPierre ProncheryX509_LOOKUP_add_store() is similar to X509_LOOKUP_add_store_ex() but 131b077aed3SPierre Proncheryuses NULL for the library context I<libctx> and property query I<propq>. 132b077aed3SPierre Pronchery 133b077aed3SPierre ProncheryX509_LOOKUP_load_store_ex() passes a URI for a single container from 134b077aed3SPierre Proncherywhich certificates and CRLs are immediately loaded into the associated 135b077aed3SPierre ProncheryB<X509_STORE>. The library context I<libctx> and property query I<propq> are used 136b077aed3SPierre Proncherywhen fetching algorithms from providers. 137b077aed3SPierre ProncheryThese functions can only be used with a lookup using the 138b077aed3SPierre Proncheryimplementation L<X509_LOOKUP_store(3)>. 139b077aed3SPierre Pronchery 140b077aed3SPierre ProncheryX509_LOOKUP_load_store() is similar to X509_LOOKUP_load_store_ex() but 141b077aed3SPierre Proncheryuses NULL for the library context I<libctx> and property query I<propq>. 142b077aed3SPierre Pronchery 143b077aed3SPierre ProncheryX509_LOOKUP_load_file_ex(), X509_LOOKUP_load_file(), 144b077aed3SPierre ProncheryX509_LOOKUP_add_dir(), 145b077aed3SPierre ProncheryX509_LOOKUP_add_store_ex() X509_LOOKUP_add_store(), 146b077aed3SPierre ProncheryX509_LOOKUP_load_store_ex() and X509_LOOKUP_load_store() are 147b077aed3SPierre Proncheryimplemented as macros that use X509_LOOKUP_ctrl(). 148b077aed3SPierre Pronchery 149b077aed3SPierre ProncheryX509_LOOKUP_by_subject_ex(), X509_LOOKUP_by_subject(), 150b077aed3SPierre ProncheryX509_LOOKUP_by_issuer_serial(), X509_LOOKUP_by_fingerprint(), and 151b077aed3SPierre ProncheryX509_LOOKUP_by_alias() look up certificates and CRLs in the L<X509_STORE(3)> 152b077aed3SPierre Proncheryassociated with the B<X509_LOOKUP> using different criteria, where the looked up 153b077aed3SPierre Proncheryobject is stored in I<ret>. 15417f01e99SJung-uk KimSome of the underlying B<X509_LOOKUP_METHOD>s will also cache objects 15517f01e99SJung-uk Kimmatching the criteria in the associated B<X509_STORE>, which makes it 15617f01e99SJung-uk Kimpossible to handle cases where the criteria have more than one hit. 15717f01e99SJung-uk Kim 15817f01e99SJung-uk Kim=head2 Control Commands 15917f01e99SJung-uk Kim 160b077aed3SPierre ProncheryThe B<X509_LOOKUP_METHOD>s built into OpenSSL recognize the following 16117f01e99SJung-uk KimX509_LOOKUP_ctrl() I<cmd>s: 16217f01e99SJung-uk Kim 16317f01e99SJung-uk Kim=over 4 16417f01e99SJung-uk Kim 16517f01e99SJung-uk Kim=item B<X509_L_FILE_LOAD> 16617f01e99SJung-uk Kim 167b077aed3SPierre ProncheryThis is the command that X509_LOOKUP_load_file_ex() and 168b077aed3SPierre ProncheryX509_LOOKUP_load_file() use. 16917f01e99SJung-uk KimThe filename is passed in I<argc>, and the type in I<argl>. 17017f01e99SJung-uk Kim 17117f01e99SJung-uk Kim=item B<X509_L_ADD_DIR> 17217f01e99SJung-uk Kim 17317f01e99SJung-uk KimThis is the command that X509_LOOKUP_add_dir() uses. 17417f01e99SJung-uk KimThe directory specification is passed in I<argc>, and the type in 17517f01e99SJung-uk KimI<argl>. 17617f01e99SJung-uk Kim 17717f01e99SJung-uk Kim=item B<X509_L_ADD_STORE> 17817f01e99SJung-uk Kim 179b077aed3SPierre ProncheryThis is the command that X509_LOOKUP_add_store_ex() and 180b077aed3SPierre ProncheryX509_LOOKUP_add_store() use. 18117f01e99SJung-uk KimThe URI is passed in I<argc>. 18217f01e99SJung-uk Kim 18317f01e99SJung-uk Kim=item B<X509_L_LOAD_STORE> 18417f01e99SJung-uk Kim 185b077aed3SPierre ProncheryThis is the command that X509_LOOKUP_load_store_ex() and 186b077aed3SPierre ProncheryX509_LOOKUP_load_store() use. 18717f01e99SJung-uk KimThe URI is passed in I<argc>. 18817f01e99SJung-uk Kim 18917f01e99SJung-uk Kim=back 19017f01e99SJung-uk Kim 19117f01e99SJung-uk Kim=head1 RETURN VALUES 19217f01e99SJung-uk Kim 193b077aed3SPierre ProncheryX509_LOOKUP_new() returns a B<X509_LOOKUP> pointer when successful, 19417f01e99SJung-uk Kimor NULL on error. 19517f01e99SJung-uk Kim 19617f01e99SJung-uk KimX509_LOOKUP_init() and X509_LOOKUP_shutdown() return 1 on success, or 19717f01e99SJung-uk Kim0 on error. 19817f01e99SJung-uk Kim 19917f01e99SJung-uk KimX509_LOOKUP_ctrl() returns -1 if the B<X509_LOOKUP> doesn't have an 20017f01e99SJung-uk Kimassociated B<X509_LOOKUP_METHOD>, or 1 if the X<509_LOOKUP_METHOD> 20117f01e99SJung-uk Kimdoesn't have a control function. 20217f01e99SJung-uk KimOtherwise, it returns what the control function in the 20317f01e99SJung-uk KimB<X509_LOOKUP_METHOD> returns, which is usually 1 on success and 0 in 20417f01e99SJung-uk Kimerror. 20517f01e99SJung-uk Kim 206b077aed3SPierre ProncheryX509_LOOKUP_get_store() returns a B<X509_STORE> pointer if there is 20717f01e99SJung-uk Kimone, otherwise NULL. 20817f01e99SJung-uk Kim 209b077aed3SPierre ProncheryX509_LOOKUP_by_subject_ex(), X509_LOOKUP_by_subject(), 210b077aed3SPierre ProncheryX509_LOOKUP_by_issuer_serial(), X509_LOOKUP_by_fingerprint(), and 211b077aed3SPierre ProncheryX509_LOOKUP_by_alias() all return 0 if there is no B<X509_LOOKUP_METHOD> or that 212b077aed3SPierre Proncherymethod doesn't implement the corresponding function. 21317f01e99SJung-uk KimOtherwise, it returns what the corresponding function in the 21417f01e99SJung-uk KimB<X509_LOOKUP_METHOD> returns, which is usually 1 on success and 0 in 21517f01e99SJung-uk Kimerror. 21617f01e99SJung-uk Kim 21717f01e99SJung-uk Kim=head1 SEE ALSO 21817f01e99SJung-uk Kim 21917f01e99SJung-uk KimL<X509_LOOKUP_METHOD(3)>, L<X509_STORE(3)> 22017f01e99SJung-uk Kim 221b077aed3SPierre Pronchery=head1 HISTORY 222b077aed3SPierre Pronchery 223b077aed3SPierre ProncheryThe functions X509_LOOKUP_by_subject_ex() and 224b077aed3SPierre ProncheryX509_LOOKUP_ctrl_ex() were added in OpenSSL 3.0. 225b077aed3SPierre Pronchery 226b077aed3SPierre ProncheryThe macros X509_LOOKUP_load_file_ex(), 227b077aed3SPierre ProncheryX509_LOOKUP_load_store_ex() and 509_LOOKUP_add_store_ex() were 228b077aed3SPierre Proncheryadded in OpenSSL 3.0. 229b077aed3SPierre Pronchery 23017f01e99SJung-uk Kim=head1 COPYRIGHT 23117f01e99SJung-uk Kim 232*a7148ab3SEnji CooperCopyright 2020-2024 The OpenSSL Project Authors. All Rights Reserved. 23317f01e99SJung-uk Kim 23417f01e99SJung-uk KimLicensed under the Apache License 2.0 (the "License"). You may not use 23517f01e99SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 23617f01e99SJung-uk Kimin the file LICENSE in the source distribution or at 23717f01e99SJung-uk KimL<https://www.openssl.org/source/license.html>. 23817f01e99SJung-uk Kim 23917f01e99SJung-uk Kim=cut 240