Debian Codegraph @

upstream/debian-unstable/man3/X509_LOOKUP.3ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "X509_LOOKUP 3SSL"
58 .TH X509_LOOKUP 3SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 X509_LOOKUP, X509_LOOKUP_TYPE,
65 X509_LOOKUP_new, X509_LOOKUP_free, X509_LOOKUP_init,
66 X509_LOOKUP_shutdown,
67 X509_LOOKUP_set_method_data, X509_LOOKUP_get_method_data,
68 X509_LOOKUP_ctrl_ex, X509_LOOKUP_ctrl,
69 X509_LOOKUP_load_file_ex, X509_LOOKUP_load_file,
70 X509_LOOKUP_add_dir,
71 X509_LOOKUP_add_store_ex, X509_LOOKUP_add_store,
72 X509_LOOKUP_load_store_ex, X509_LOOKUP_load_store,
73 X509_LOOKUP_get_store,
74 X509_LOOKUP_by_subject_ex, X509_LOOKUP_by_subject,
75 X509_LOOKUP_by_issuer_serial, X509_LOOKUP_by_fingerprint,
76 X509_LOOKUP_by_alias
77 \&\- OpenSSL certificate lookup mechanisms
78 .SH SYNOPSIS
79 .IX Header "SYNOPSIS"
80 .Vb 1
81 \& #include <openssl/x509_vfy.h>
82 \&
83 \& typedef x509_lookup_st X509_LOOKUP;
84 \&
85 \& typedef enum X509_LOOKUP_TYPE;
86 \&
87 \& X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);
88 \& int X509_LOOKUP_init(X509_LOOKUP *ctx);
89 \& int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
90 \& void X509_LOOKUP_free(X509_LOOKUP *ctx);
91 \&
92 \& int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data);
93 \& void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx);
94 \&
95 \& int X509_LOOKUP_ctrl_ex(X509_LOOKUP *ctx, int cmd, const char *argc, long argl,
96 \& char **ret, OSSL_LIB_CTX *libctx, const char *propq);
97 \& int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
98 \& long argl, char **ret);
99 \& int X509_LOOKUP_load_file_ex(X509_LOOKUP *ctx, char *name, long type,
100 \& OSSL_LIB_CTX *libctx, const char *propq);
101 \& int X509_LOOKUP_load_file(X509_LOOKUP *ctx, char *name, long type);
102 \& int X509_LOOKUP_load_file_ex(X509_LOOKUP *ctx, char *name, long type,
103 \& OSSL_LIB_CTX *libctx, const char *propq);
104 \& int X509_LOOKUP_add_dir(X509_LOOKUP *ctx, char *name, long type);
105 \& int X509_LOOKUP_add_store_ex(X509_LOOKUP *ctx, char *uri, OSSL_LIB_CTX *libctx,
106 \& const char *propq);
107 \& int X509_LOOKUP_add_store(X509_LOOKUP *ctx, char *uri);
108 \& int X509_LOOKUP_load_store_ex(X509_LOOKUP *ctx, char *uri, OSSL_LIB_CTX *libctx,
109 \& const char *propq);
110 \& int X509_LOOKUP_load_store(X509_LOOKUP *ctx, char *uri);
111 \&
112 \& X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx);
113 \&
114 \& int X509_LOOKUP_by_subject_ex(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
115 \& const X509_NAME *name, X509_OBJECT *ret,
116 \& OSSL_LIB_CTX *libctx, const char *propq);
117 \& int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
118 \& const X509_NAME *name, X509_OBJECT *ret);
119 \& int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
120 \& const X509_NAME *name,
121 \& const ASN1_INTEGER *serial, X509_OBJECT *ret);
122 \& int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
123 \& const unsigned char *bytes, int len,
124 \& X509_OBJECT *ret);
125 \& int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
126 \& const char *str, int len, X509_OBJECT *ret);
127 .Ve
128 .SH DESCRIPTION
129 .IX Header "DESCRIPTION"
130 The \fBX509_LOOKUP\fR structure holds the information needed to look up
131 certificates and CRLs according to an associated \fBX509_LOOKUP_METHOD\fR\|(3).
132 Multiple \fBX509_LOOKUP\fR instances can be added to an \fBX509_STORE\fR\|(3)
133 to enable lookup in that store.
134 .PP
135 \&\fBX509_LOOKUP_new()\fR creates a new \fBX509_LOOKUP\fR using the given lookup
136 \&\fImethod\fR.
137 It can also be created by calling \fBX509_STORE_add_lookup\fR\|(3), which
138 will associate a \fBX509_STORE\fR with the lookup mechanism.
139 .PP
140 \&\fBX509_LOOKUP_init()\fR initializes the internal state and resources as
141 needed by the given \fBX509_LOOKUP\fR to do its work.
142 .PP
143 \&\fBX509_LOOKUP_shutdown()\fR tears down the internal state and resources of
144 the given \fBX509_LOOKUP\fR.
145 .PP
146 \&\fBX509_LOOKUP_free()\fR destructs the given \fBX509_LOOKUP\fR.
147 If the argument is NULL, nothing is done.
148 .PP
149 \&\fBX509_LOOKUP_set_method_data()\fR and \fBX509_LOOKUP_get_method_data()\fR
150 associates and retrieves a pointer to application data to and from the
151 given \fBX509_LOOKUP\fR, respectively.
152 .PP
153 \&\fBX509_LOOKUP_ctrl_ex()\fR is used to set or get additional data to or from
154 a \fBX509_LOOKUP\fR structure using any control function in the
155 associated \fBX509_LOOKUP_METHOD\fR\|(3).
156 The arguments of the control command are passed via \fIargc\fR and \fIargl\fR,
157 its return value via \fI*ret\fR. The library context \fIlibctx\fR and property
158 query \fIpropq\fR are used when fetching algorithms from providers.
159 The meaning of the arguments depends on the \fIcmd\fR number of the
160 control command. In general, this function is not called directly, but
161 wrapped by a macro call, see below.
162 The control \fIcmd\fRs known to OpenSSL are discussed in more depth
163 in "Control Commands".
164 .PP
165 \&\fBX509_LOOKUP_ctrl()\fR is similar to \fBX509_LOOKUP_ctrl_ex()\fR but
166 uses NULL for the library context \fIlibctx\fR and property query \fIpropq\fR.
167 .PP
168 \&\fBX509_LOOKUP_load_file_ex()\fR passes a filename to be loaded immediately
169 into the associated \fBX509_STORE\fR. The library context \fIlibctx\fR and property
170 query \fIpropq\fR are used when fetching algorithms from providers.
171 \&\fItype\fR indicates what type of object is expected.
172 This can only be used with a lookup using the implementation
173 \&\fBX509_LOOKUP_file\fR\|(3).
174 .PP
175 \&\fBX509_LOOKUP_load_file()\fR is similar to \fBX509_LOOKUP_load_file_ex()\fR but
176 uses NULL for the library context \fIlibctx\fR and property query \fIpropq\fR.
177 .PP
178 \&\fBX509_LOOKUP_add_dir()\fR passes a directory specification from which
179 certificates and CRLs are loaded on demand into the associated
180 \&\fBX509_STORE\fR.
181 \&\fItype\fR indicates what type of object is expected.
182 This can only be used with a lookup using the implementation
183 \&\fBX509_LOOKUP_hash_dir\fR\|(3).
184 .PP
185 \&\fBX509_LOOKUP_add_store_ex()\fR passes a URI for a directory-like structure
186 from which containers with certificates and CRLs are loaded on demand
187 into the associated \fBX509_STORE\fR. The library context \fIlibctx\fR and property
188 query \fIpropq\fR are used when fetching algorithms from providers.
189 .PP
190 \&\fBX509_LOOKUP_add_store()\fR is similar to \fBX509_LOOKUP_add_store_ex()\fR but
191 uses NULL for the library context \fIlibctx\fR and property query \fIpropq\fR.
192 .PP
193 \&\fBX509_LOOKUP_load_store_ex()\fR passes a URI for a single container from
194 which certificates and CRLs are immediately loaded into the associated
195 \&\fBX509_STORE\fR. The library context \fIlibctx\fR and property query \fIpropq\fR are used
196 when fetching algorithms from providers.
197 These functions can only be used with a lookup using the
198 implementation \fBX509_LOOKUP_store\fR\|(3).
199 .PP
200 \&\fBX509_LOOKUP_load_store()\fR is similar to \fBX509_LOOKUP_load_store_ex()\fR but
201 uses NULL for the library context \fIlibctx\fR and property query \fIpropq\fR.
202 .PP
203 \&\fBX509_LOOKUP_load_file_ex()\fR, \fBX509_LOOKUP_load_file()\fR,
204 \&\fBX509_LOOKUP_add_dir()\fR,
205 \&\fBX509_LOOKUP_add_store_ex()\fR \fBX509_LOOKUP_add_store()\fR,
206 \&\fBX509_LOOKUP_load_store_ex()\fR and \fBX509_LOOKUP_load_store()\fR are
207 implemented as macros that use \fBX509_LOOKUP_ctrl()\fR.
208 .PP
209 \&\fBX509_LOOKUP_by_subject_ex()\fR, \fBX509_LOOKUP_by_subject()\fR,
210 \&\fBX509_LOOKUP_by_issuer_serial()\fR, \fBX509_LOOKUP_by_fingerprint()\fR, and
211 \&\fBX509_LOOKUP_by_alias()\fR look up certificates and CRLs in the \fBX509_STORE\fR\|(3)
212 associated with the \fBX509_LOOKUP\fR using different criteria, where the looked up
213 object is stored in \fIret\fR.
214 Some of the underlying \fBX509_LOOKUP_METHOD\fRs will also cache objects
215 matching the criteria in the associated \fBX509_STORE\fR, which makes it
216 possible to handle cases where the criteria have more than one hit.
217 .SS "Control Commands"
218 .IX Subsection "Control Commands"
219 The \fBX509_LOOKUP_METHOD\fRs built into OpenSSL recognize the following
220 \&\fBX509_LOOKUP_ctrl()\fR \fIcmd\fRs:
221 .IP \fBX509_L_FILE_LOAD\fR 4
222 .IX Item "X509_L_FILE_LOAD"
223 This is the command that \fBX509_LOOKUP_load_file_ex()\fR and
224 \&\fBX509_LOOKUP_load_file()\fR use.
225 The filename is passed in \fIargc\fR, and the type in \fIargl\fR.
226 .IP \fBX509_L_ADD_DIR\fR 4
227 .IX Item "X509_L_ADD_DIR"
228 This is the command that \fBX509_LOOKUP_add_dir()\fR uses.
229 The directory specification is passed in \fIargc\fR, and the type in
230 \&\fIargl\fR.
231 .IP \fBX509_L_ADD_STORE\fR 4
232 .IX Item "X509_L_ADD_STORE"
233 This is the command that \fBX509_LOOKUP_add_store_ex()\fR and
234 \&\fBX509_LOOKUP_add_store()\fR use.
235 The URI is passed in \fIargc\fR.
236 .IP \fBX509_L_LOAD_STORE\fR 4
237 .IX Item "X509_L_LOAD_STORE"
238 This is the command that \fBX509_LOOKUP_load_store_ex()\fR and
239 \&\fBX509_LOOKUP_load_store()\fR use.
240 The URI is passed in \fIargc\fR.
241 .SH "RETURN VALUES"
242 .IX Header "RETURN VALUES"
243 \&\fBX509_LOOKUP_new()\fR returns a \fBX509_LOOKUP\fR pointer when successful,
244 or NULL on error.
245 .PP
246 \&\fBX509_LOOKUP_init()\fR and \fBX509_LOOKUP_shutdown()\fR return 1 on success, or
247 0 on error.
248 .PP
249 \&\fBX509_LOOKUP_ctrl_ex()\fR and \fBX509_LOOKUP_ctrl()\fR
250 return \-1 if the \fBX509_LOOKUP\fR doesn't have an
251 associated \fBX509_LOOKUP_METHOD\fR, or 1 if the
252 doesn't have a control function.
253 Otherwise, it returns what the control function in the
254 \&\fBX509_LOOKUP_METHOD\fR returns, which is usually 1 on success and 0 on error
255 but could also be \-1 on failure.
256 .IX Xref "509_LOOKUP_METHOD"
257 .PP
258 \&\fBX509_LOOKUP_get_store()\fR returns a \fBX509_STORE\fR pointer if there is
259 one, otherwise NULL.
260 .PP
261 \&\fBX509_LOOKUP_by_subject_ex()\fR returns 0 if there is no \fBX509_LOOKUP_METHOD\fR
262 that implements any of the \fBget_by_subject_ex()\fR or \fBget_by_subject()\fR functions.
263 It calls \fBget_by_subject_ex()\fR if present, otherwise \fBget_by_subject()\fR, and returns
264 the result of the function, which is usually 1 on success and 0 on error.
265 .PP
266 \&\fBX509_LOOKUP_by_subject()\fR is similar to \fBX509_LOOKUP_by_subject_ex()\fR
267 but passes NULL for both the libctx and propq.
268 .PP
269 \&\fBX509_LOOKUP_by_issuer_serial()\fR, \fBX509_LOOKUP_by_fingerprint()\fR, and
270 \&\fBX509_LOOKUP_by_alias()\fR all return 0 if there is no \fBX509_LOOKUP_METHOD\fR or that
271 method doesn't implement the corresponding function.
272 Otherwise, they return what the corresponding function in the
273 \&\fBX509_LOOKUP_METHOD\fR returns, which is usually 1 on success and 0 in
274 error.
275 .SH "SEE ALSO"
276 .IX Header "SEE ALSO"
277 \&\fBX509_LOOKUP_METHOD\fR\|(3), \fBX509_STORE\fR\|(3)
278 .SH HISTORY
279 .IX Header "HISTORY"
280 The functions \fBX509_LOOKUP_by_subject_ex()\fR and
281 \&\fBX509_LOOKUP_ctrl_ex()\fR were added in OpenSSL 3.0.
282 .PP
283 The macros \fBX509_LOOKUP_load_file_ex()\fR,
284 \&\fBX509_LOOKUP_load_store_ex()\fR and \fBX509_LOOKUP_add_store_ex()\fR were
285 added in OpenSSL 3.0.
286 .SH COPYRIGHT
287 .IX Header "COPYRIGHT"
288 Copyright 2020\-2025 The OpenSSL Project Authors. All Rights Reserved.
289 .PP
290 Licensed under the Apache License 2.0 (the "License"). You may not use
291 this file except in compliance with the License. You can obtain a copy
292 in the file LICENSE in the source distribution or at
293 <https://www.openssl.org/source/license.html>.