1X509_LOOKUP(3) OpenSSL X509_LOOKUP(3)
2
3
4
6 X509_LOOKUP, X509_LOOKUP_TYPE, X509_LOOKUP_new, X509_LOOKUP_free,
7 X509_LOOKUP_init, X509_LOOKUP_shutdown, X509_LOOKUP_set_method_data,
8 X509_LOOKUP_get_method_data, X509_LOOKUP_ctrl, X509_LOOKUP_load_file,
9 X509_LOOKUP_add_dir, X509_LOOKUP_get_store, X509_LOOKUP_by_subject,
10 X509_LOOKUP_by_issuer_serial, X509_LOOKUP_by_fingerprint,
11 X509_LOOKUP_by_alias - OpenSSL certificate lookup mechanisms
12
14 #include <openssl/x509_vfy.h>
15
16 typedef x509_lookup_st X509_LOOKUP;
17
18 typedef enum X509_LOOKUP_TYPE;
19
20 X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);
21 int X509_LOOKUP_init(X509_LOOKUP *ctx);
22 int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
23 void X509_LOOKUP_free(X509_LOOKUP *ctx);
24
25 int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data);
26 void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx);
27
28 int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
29 long argl, char **ret);
30 int X509_LOOKUP_load_file(X509_LOOKUP *ctx, char *name, long type);
31 int X509_LOOKUP_add_dir(X509_LOOKUP *ctx, char *name, long type);
32
33 X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx);
34
35 int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
36 X509_NAME *name, X509_OBJECT *ret);
37 int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
38 X509_NAME *name, ASN1_INTEGER *serial,
39 X509_OBJECT *ret);
40 int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
41 const unsigned char *bytes, int len,
42 X509_OBJECT *ret);
43 int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
44 const char *str, int len, X509_OBJECT *ret);
45
47 The X509_LOOKUP structure holds the information needed to look up
48 certificates and CRLs according to an associated X509_LOOKUP_METHOD(3).
49 Multiple X509_LOOKUP instances can be added to an X509_STORE(3) to
50 enable lookup in that store.
51
52 X509_LOOKUP_new() creates a new X509_LOOKUP using the given lookup
53 method. It can also be created by calling X509_STORE_add_lookup(3),
54 which will associate an X509_STORE with the lookup mechanism.
55
56 X509_LOOKUP_init() initializes the internal state and resources as
57 needed by the given X509_LOOKUP to do its work.
58
59 X509_LOOKUP_shutdown() tears down the internal state and resources of
60 the given X509_LOOKUP.
61
62 X509_LOOKUP_free() destructs the given X509_LOOKUP.
63
64 X509_LOOKUP_set_method_data() associates a pointer to application data
65 to the given X509_LOOKUP.
66
67 X509_LOOKUP_get_method_data() retrieves a pointer to application data
68 from the given X509_LOOKUP.
69
70 X509_LOOKUP_ctrl() is used to set or get additional data to or from an
71 X509_LOOKUP structure or its associated X509_LOOKUP_METHOD(3). The
72 arguments of the control command are passed via argc and argl, its
73 return value via *ret. The meaning of the arguments depends on the cmd
74 number of the control command. In general, this function is not called
75 directly, but wrapped by a macro call, see below. The control cmds
76 known to OpenSSL are discussed in more depth in "Control Commands".
77
78 X509_LOOKUP_load_file() passes a filename to be loaded immediately into
79 the associated X509_STORE. type indicates what type of object is
80 expected. This can only be used with a lookup using the implementation
81 X509_LOOKUP_file(3).
82
83 X509_LOOKUP_add_dir() passes a directory specification from which
84 certificates and CRLs are loaded on demand into the associated
85 X509_STORE. type indicates what type of object is expected. This can
86 only be used with a lookup using the implementation
87 X509_LOOKUP_hash_dir(3).
88
89 X509_LOOKUP_load_file(), X509_LOOKUP_add_dir(),
90 X509_LOOKUP_add_store(), and X509_LOOKUP_load_store() are implemented
91 as macros that use X509_LOOKUP_ctrl().
92
93 X509_LOOKUP_by_subject(), X509_LOOKUP_by_issuer_serial(),
94 X509_LOOKUP_by_fingerprint(), and X509_LOOKUP_by_alias() look up
95 certificates and CRLs in the X509_STORE(3) associated with the
96 X509_LOOKUP using different criteria, where the looked up object is
97 stored in ret. Some of the underlying X509_LOOKUP_METHODs will also
98 cache objects matching the criteria in the associated X509_STORE, which
99 makes it possible to handle cases where the criteria have more than one
100 hit.
101
102 File Types
103 X509_LOOKUP_load_file() and X509_LOOKUP_add_dir() take a type, which
104 can be one of the following:
105
106 X509_FILETYPE_PEM
107 The file or files that are loaded are expected to be in PEM format.
108
109 X509_FILETYPE_ASN1
110 The file or files that are loaded are expected to be in raw DER
111 format.
112
113 X509_FILETYPE_DEFAULT
114 The default certificate file or directory is used. In this case,
115 name is ignored.
116
117 Control Commands
118 The X509_LOOKUP_METHODs built into OpenSSL recognise the following
119 X509_LOOKUP_ctrl() cmds:
120
121 X509_L_FILE_LOAD
122 This is the command that X509_LOOKUP_load_file() uses. The
123 filename is passed in argc, and the type in argl.
124
125 X509_L_ADD_DIR
126 This is the command that X509_LOOKUP_add_dir() uses. The directory
127 specification is passed in argc, and the type in argl.
128
129 X509_L_ADD_STORE
130 This is the command that X509_LOOKUP_add_store() uses. The URI is
131 passed in argc.
132
133 X509_L_LOAD_STORE
134 This is the command that X509_LOOKUP_load_store() uses. The URI is
135 passed in argc.
136
138 X509_LOOKUP_new() returns an X509_LOOKUP pointer when successful, or
139 NULL on error.
140
141 X509_LOOKUP_init() and X509_LOOKUP_shutdown() return 1 on success, or 0
142 on error.
143
144 X509_LOOKUP_ctrl() returns -1 if the X509_LOOKUP doesn't have an
145 associated X509_LOOKUP_METHOD, or 1 if the doesn't have a control
146 function. Otherwise, it returns what the control function in the
147 X509_LOOKUP_METHOD returns, which is usually 1 on success and 0 in
148 error.
149
150 X509_LOOKUP_get_store() returns an X509_STORE pointer if there is one,
151 otherwise NULL.
152
153 X509_LOOKUP_by_subject(), X509_LOOKUP_by_issuer_serial(),
154 X509_LOOKUP_by_fingerprint(), and X509_LOOKUP_by_alias() all return 0
155 if there is no X509_LOOKUP_METHOD or that method doesn't implement the
156 corresponding function. Otherwise, it returns what the corresponding
157 function in the X509_LOOKUP_METHOD returns, which is usually 1 on
158 success and 0 in error.
159
161 X509_LOOKUP_METHOD(3), X509_STORE(3)
162
164 Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
165
166 Licensed under the Apache License 2.0 (the "License"). You may not use
167 this file except in compliance with the License. You can obtain a copy
168 in the file LICENSE in the source distribution or at
169 <https://www.openssl.org/source/license.html>.
170
171
172
1731.1.1l 2021-09-15 X509_LOOKUP(3)