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,
11 X509_LOOKUP_get_store, X509_LOOKUP_by_subject,
12 X509_LOOKUP_by_issuer_serial, X509_LOOKUP_by_fingerprint,
14 - OpenSSL certificate lookup mechanisms
18 #include <openssl/x509_vfy.h>
20 typedef x509_lookup_st X509_LOOKUP;
22 typedef enum X509_LOOKUP_TYPE;
24 X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);
25 int X509_LOOKUP_init(X509_LOOKUP *ctx);
26 int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
27 void X509_LOOKUP_free(X509_LOOKUP *ctx);
29 int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data);
30 void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx);
32 int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
33 long argl, char **ret);
34 int X509_LOOKUP_load_file(X509_LOOKUP *ctx, char *name, long type);
35 int X509_LOOKUP_add_dir(X509_LOOKUP *ctx, char *name, long type);
37 X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx);
39 int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
40 X509_NAME *name, X509_OBJECT *ret);
41 int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
42 X509_NAME *name, ASN1_INTEGER *serial,
44 int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
45 const unsigned char *bytes, int len,
47 int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
48 const char *str, int len, X509_OBJECT *ret);
52 The B<X509_LOOKUP> structure holds the information needed to look up
53 certificates and CRLs according to an associated L<X509_LOOKUP_METHOD(3)>.
54 Multiple B<X509_LOOKUP> instances can be added to an L<X509_STORE(3)>
55 to enable lookup in that store.
57 X509_LOOKUP_new() creates a new B<X509_LOOKUP> using the given lookup
59 It can also be created by calling L<X509_STORE_add_lookup(3)>, which
60 will associate a B<X509_STORE> with the lookup mechanism.
62 X509_LOOKUP_init() initializes the internal state and resources as
63 needed by the given B<X509_LOOKUP> to do its work.
65 X509_LOOKUP_shutdown() tears down the internal state and resources of
66 the given B<X509_LOOKUP>.
68 X509_LOOKUP_free() destructs the given B<X509_LOOKUP>.
70 X509_LOOKUP_set_method_data() and X509_LOOKUP_get_method_data()
71 associates and retrieves a pointer to application data to and from the
72 given B<X509_LOOKUP>, respectively.
74 X509_LOOKUP_ctrl() is used to set or get additional data to or from a
75 B<X509_LOOKUP> structure or its associated L<X509_LOOKUP_METHOD(3)>.
76 The arguments of the control command are passed via I<argc> and I<argl>,
77 its return value via I<*ret>.
78 The meaning of the arguments depends on the I<cmd> number of the
79 control command. In general, this function is not called directly, but
80 wrapped by a macro call, see below.
81 The control I<cmd>s known to OpenSSL are discussed in more depth
82 in L</Control Commands>.
84 X509_LOOKUP_load_file() passes a filename to be loaded immediately
85 into the associated B<X509_STORE>.
86 I<type> indicates what type of object is expected.
87 This can only be used with a lookup using the implementation
88 L<X509_LOOKUP_file(3)>.
90 X509_LOOKUP_add_dir() passes a directory specification from which
91 certificates and CRLs are loaded on demand into the associated
93 I<type> indicates what type of object is expected.
94 This can only be used with a lookup using the implementation
95 L<X509_LOOKUP_hash_dir(3)>.
97 X509_LOOKUP_load_file(), X509_LOOKUP_add_dir(),
98 X509_LOOKUP_add_store(), and X509_LOOKUP_load_store() are implemented
99 as macros that use X509_LOOKUP_ctrl().
101 X509_LOOKUP_by_subject(), X509_LOOKUP_by_issuer_serial(),
102 X509_LOOKUP_by_fingerprint(), and X509_LOOKUP_by_alias() look up
103 certificates and CRLs in the L<X509_STORE(3)> associated with the
104 B<X509_LOOKUP> using different criteria, where the looked up object is
106 Some of the underlying B<X509_LOOKUP_METHOD>s will also cache objects
107 matching the criteria in the associated B<X509_STORE>, which makes it
108 possible to handle cases where the criteria have more than one hit.
110 =head2 Control Commands
112 The B<X509_LOOKUP_METHOD>s built into OpenSSL recognise the following
113 X509_LOOKUP_ctrl() I<cmd>s:
117 =item B<X509_L_FILE_LOAD>
119 This is the command that X509_LOOKUP_load_file() uses.
120 The filename is passed in I<argc>, and the type in I<argl>.
122 =item B<X509_L_ADD_DIR>
124 This is the command that X509_LOOKUP_add_dir() uses.
125 The directory specification is passed in I<argc>, and the type in
128 =item B<X509_L_ADD_STORE>
130 This is the command that X509_LOOKUP_add_store() uses.
131 The URI is passed in I<argc>.
133 =item B<X509_L_LOAD_STORE>
135 This is the command that X509_LOOKUP_load_store() uses.
136 The URI is passed in I<argc>.
142 X509_LOOKUP_new() returns a B<X509_LOOKUP> pointer when successful,
145 X509_LOOKUP_init() and X509_LOOKUP_shutdown() return 1 on success, or
148 X509_LOOKUP_ctrl() returns -1 if the B<X509_LOOKUP> doesn't have an
149 associated B<X509_LOOKUP_METHOD>, or 1 if the X<509_LOOKUP_METHOD>
150 doesn't have a control function.
151 Otherwise, it returns what the control function in the
152 B<X509_LOOKUP_METHOD> returns, which is usually 1 on success and 0 in
155 X509_LOOKUP_get_store() returns a B<X509_STORE> pointer if there is
158 X509_LOOKUP_by_subject(), X509_LOOKUP_by_issuer_serial(),
159 X509_LOOKUP_by_fingerprint(), and X509_LOOKUP_by_alias() all return 0
160 if there is no B<X509_LOOKUP_METHOD> or that method doesn't implement
161 the corresponding function.
162 Otherwise, it returns what the corresponding function in the
163 B<X509_LOOKUP_METHOD> returns, which is usually 1 on success and 0 in
168 L<X509_LOOKUP_METHOD(3)>, L<X509_STORE(3)>
172 Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
174 Licensed under the Apache License 2.0 (the "License"). You may not use
175 this file except in compliance with the License. You can obtain a copy
176 in the file LICENSE in the source distribution or at
177 L<https://www.openssl.org/source/license.html>.