5 X509_LOOKUP, X509_LOOKUP_TYPE,
6 X509_LOOKUP_new, X509_LOOKUP_free, X509_LOOKUP_init,
8 X509_LOOKUP_set_method_data, X509_LOOKUP_get_method_data,
10 X509_LOOKUP_load_file, X509_LOOKUP_add_dir, X509_LOOKUP_add_store,
11 X509_LOOKUP_load_store,
12 X509_LOOKUP_get_store, X509_LOOKUP_by_subject,
13 X509_LOOKUP_by_issuer_serial, X509_LOOKUP_by_fingerprint,
15 - OpenSSL certificate lookup mechanisms
19 #include <openssl/x509_vfy.h>
21 typedef x509_lookup_st X509_LOOKUP;
23 typedef enum X509_LOOKUP_TYPE;
25 X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);
26 int X509_LOOKUP_init(X509_LOOKUP *ctx);
27 int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
28 void X509_LOOKUP_free(X509_LOOKUP *ctx);
30 int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data);
31 void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx);
33 int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
34 long argl, char **ret);
35 int X509_LOOKUP_load_file(X509_LOOKUP *ctx, char *name, long type);
36 int X509_LOOKUP_add_dir(X509_LOOKUP *ctx, char *name, long type);
37 int X509_LOOKUP_add_store(X509_LOOKUP *ctx, char *uri);
38 int X509_LOOKUP_load_store(X509_LOOKUP *ctx, char *uri);
40 X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx);
42 int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
43 const X509_NAME *name, X509_OBJECT *ret);
44 int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
45 const X509_NAME *name,
46 const ASN1_INTEGER *serial, X509_OBJECT *ret);
47 int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
48 const unsigned char *bytes, int len,
50 int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
51 const char *str, int len, X509_OBJECT *ret);
55 The B<X509_LOOKUP> structure holds the information needed to look up
56 certificates and CRLs according to an associated L<X509_LOOKUP_METHOD(3)>.
57 Multiple B<X509_LOOKUP> instances can be added to an L<X509_STORE(3)>
58 to enable lookup in that store.
60 X509_LOOKUP_new() creates a new B<X509_LOOKUP> using the given lookup
62 It can also be created by calling L<X509_STORE_add_lookup(3)>, which
63 will associate a B<X509_STORE> with the lookup mechanism.
65 X509_LOOKUP_init() initializes the internal state and resources as
66 needed by the given B<X509_LOOKUP> to do its work.
68 X509_LOOKUP_shutdown() tears down the internal state and resources of
69 the given B<X509_LOOKUP>.
71 X509_LOOKUP_free() destructs the given B<X509_LOOKUP>.
73 X509_LOOKUP_set_method_data() and X509_LOOKUP_get_method_data()
74 associates and retrieves a pointer to application data to and from the
75 given B<X509_LOOKUP>, respectively.
77 X509_LOOKUP_ctrl() is used to set or get additional data to or from a
78 B<X509_LOOKUP> structure or its associated L<X509_LOOKUP_METHOD(3)>.
79 The arguments of the control command are passed via I<argc> and I<argl>,
80 its return value via I<*ret>.
81 The meaning of the arguments depends on the I<cmd> number of the
82 control command. In general, this function is not called directly, but
83 wrapped by a macro call, see below.
84 The control I<cmd>s known to OpenSSL are discussed in more depth
85 in L</Control Commands>.
87 X509_LOOKUP_load_file() passes a filename to be loaded immediately
88 into the associated B<X509_STORE>.
89 I<type> indicates what type of object is expected.
90 This can only be used with a lookup using the implementation
91 L<X509_LOOKUP_file(3)>.
93 X509_LOOKUP_add_dir() passes a directory specification from which
94 certificates and CRLs are loaded on demand into the associated
96 I<type> indicates what type of object is expected.
97 This can only be used with a lookup using the implementation
98 L<X509_LOOKUP_hash_dir(3)>.
100 X509_LOOKUP_add_store() passes a URI for a directory-like structure
101 from which containers with certificates and CRLs are loaded on demand
102 into the associated B<X509_STORE>.
103 X509_LOOKUP_load_store() passes a URI for a single container from
104 which certificates and CRLs are immediately loaded into the associated
106 These functions can only be used with a lookup using the
107 implementation L<X509_LOOKUP_store(3)>.
109 X509_LOOKUP_load_file(), X509_LOOKUP_add_dir(),
110 X509_LOOKUP_add_store(), and X509_LOOKUP_load_store() are implemented
111 as macros that use X509_LOOKUP_ctrl().
113 X509_LOOKUP_by_subject(), X509_LOOKUP_by_issuer_serial(),
114 X509_LOOKUP_by_fingerprint(), and X509_LOOKUP_by_alias() look up
115 certificates and CRLs in the L<X509_STORE(3)> associated with the
116 B<X509_LOOKUP> using different criteria, where the looked up object is
118 Some of the underlying B<X509_LOOKUP_METHOD>s will also cache objects
119 matching the criteria in the associated B<X509_STORE>, which makes it
120 possible to handle cases where the criteria have more than one hit.
122 =head2 Control Commands
124 The B<X509_LOOKUP_METHOD>s built into OpenSSL recognise the following
125 X509_LOOKUP_ctrl() I<cmd>s:
129 =item B<X509_L_FILE_LOAD>
131 This is the command that X509_LOOKUP_load_file() uses.
132 The filename is passed in I<argc>, and the type in I<argl>.
134 =item B<X509_L_ADD_DIR>
136 This is the command that X509_LOOKUP_add_dir() uses.
137 The directory specification is passed in I<argc>, and the type in
140 =item B<X509_L_ADD_STORE>
142 This is the command that X509_LOOKUP_add_store() uses.
143 The URI is passed in I<argc>.
145 =item B<X509_L_LOAD_STORE>
147 This is the command that X509_LOOKUP_load_store() uses.
148 The URI is passed in I<argc>.
154 X509_LOOKUP_new() returns a B<X509_LOOKUP> pointer when successful,
157 X509_LOOKUP_init() and X509_LOOKUP_shutdown() return 1 on success, or
160 X509_LOOKUP_ctrl() returns -1 if the B<X509_LOOKUP> doesn't have an
161 associated B<X509_LOOKUP_METHOD>, or 1 if the X<509_LOOKUP_METHOD>
162 doesn't have a control function.
163 Otherwise, it returns what the control function in the
164 B<X509_LOOKUP_METHOD> returns, which is usually 1 on success and 0 in
167 X509_LOOKUP_get_store() returns a B<X509_STORE> pointer if there is
170 X509_LOOKUP_by_subject(), X509_LOOKUP_by_issuer_serial(),
171 X509_LOOKUP_by_fingerprint(), and X509_LOOKUP_by_alias() all return 0
172 if there is no B<X509_LOOKUP_METHOD> or that method doesn't implement
173 the corresponding function.
174 Otherwise, it returns what the corresponding function in the
175 B<X509_LOOKUP_METHOD> returns, which is usually 1 on success and 0 in
180 L<X509_LOOKUP_METHOD(3)>, L<X509_STORE(3)>
184 Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
186 Licensed under the Apache License 2.0 (the "License"). You may not use
187 this file except in compliance with the License. You can obtain a copy
188 in the file LICENSE in the source distribution or at
189 L<https://www.openssl.org/source/license.html>.