1=pod
2
3=head1 NAME
4
5X509_STORE_set_lookup_crls_cb,
6X509_STORE_set_verify_func,
7X509_STORE_get_cleanup,
8X509_STORE_set_cleanup,
9X509_STORE_get_lookup_crls,
10X509_STORE_set_lookup_crls,
11X509_STORE_get_lookup_certs,
12X509_STORE_set_lookup_certs,
13X509_STORE_get_check_policy,
14X509_STORE_set_check_policy,
15X509_STORE_get_cert_crl,
16X509_STORE_set_cert_crl,
17X509_STORE_get_check_crl,
18X509_STORE_set_check_crl,
19X509_STORE_get_get_crl,
20X509_STORE_set_get_crl,
21X509_STORE_get_check_revocation,
22X509_STORE_set_check_revocation,
23X509_STORE_get_check_issued,
24X509_STORE_set_check_issued,
25X509_STORE_CTX_get1_issuer,
26X509_STORE_get_get_issuer,
27X509_STORE_set_get_issuer,
28X509_STORE_CTX_get_verify,
29X509_STORE_set_verify,
30X509_STORE_get_verify_cb,
31X509_STORE_set_verify_cb_func, X509_STORE_set_verify_cb,
32X509_STORE_CTX_cert_crl_fn, X509_STORE_CTX_check_crl_fn,
33X509_STORE_CTX_check_issued_fn, X509_STORE_CTX_check_policy_fn,
34X509_STORE_CTX_check_revocation_fn, X509_STORE_CTX_cleanup_fn,
35X509_STORE_CTX_get_crl_fn, X509_STORE_CTX_get_issuer_fn,
36X509_STORE_CTX_lookup_certs_fn, X509_STORE_CTX_lookup_crls_fn
37- set verification callback
38
39=head1 SYNOPSIS
40
41 #include <openssl/x509_vfy.h>
42
43 typedef int (*X509_STORE_CTX_get_issuer_fn)(X509 **issuer,
44                                             X509_STORE_CTX *ctx, X509 *x);
45 typedef int (*X509_STORE_CTX_check_issued_fn)(X509_STORE_CTX *ctx,
46                                               X509 *x, X509 *issuer);
47 typedef int (*X509_STORE_CTX_check_revocation_fn)(X509_STORE_CTX *ctx);
48 typedef int (*X509_STORE_CTX_get_crl_fn)(X509_STORE_CTX *ctx,
49                                          X509_CRL **crl, X509 *x);
50 typedef int (*X509_STORE_CTX_check_crl_fn)(X509_STORE_CTX *ctx, X509_CRL *crl);
51 typedef int (*X509_STORE_CTX_cert_crl_fn)(X509_STORE_CTX *ctx,
52                                           X509_CRL *crl, X509 *x);
53 typedef int (*X509_STORE_CTX_check_policy_fn)(X509_STORE_CTX *ctx);
54 typedef STACK_OF(X509) *(*X509_STORE_CTX_lookup_certs_fn)(X509_STORE_CTX *ctx,
55                                                           const X509_NAME *nm);
56 typedef STACK_OF(X509_CRL) *(*X509_STORE_CTX_lookup_crls_fn)(const
57                                                              X509_STORE_CTX *ctx,
58                                                              const X509_NAME *nm);
59 typedef int (*X509_STORE_CTX_cleanup_fn)(X509_STORE_CTX *ctx);
60
61 void X509_STORE_set_verify_cb(X509_STORE *xs,
62                               X509_STORE_CTX_verify_cb verify_cb);
63 X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(const X509_STORE_CTX *ctx);
64
65 void X509_STORE_set_verify(X509_STORE *xs, X509_STORE_CTX_verify_fn verify);
66 X509_STORE_CTX_verify_fn X509_STORE_CTX_get_verify(const X509_STORE_CTX *ctx);
67
68 int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
69 X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(const X509_STORE_CTX *ctx);
70 void X509_STORE_set_get_issuer(X509_STORE *xs,
71                                X509_STORE_CTX_get_issuer_fn get_issuer);
72
73 void X509_STORE_set_check_issued(X509_STORE *xs,
74                                  X509_STORE_CTX_check_issued_fn check_issued);
75 X509_STORE_CTX_check_issued_fn
76     X509_STORE_get_check_issued(const X509_STORE_CTX *ctx);
77
78 void X509_STORE_set_check_revocation(X509_STORE *xs,
79                                      X509_STORE_CTX_check_revocation_fn check_revocation);
80 X509_STORE_CTX_check_revocation_fn
81     X509_STORE_get_check_revocation(const X509_STORE_CTX *ctx);
82
83 void X509_STORE_set_get_crl(X509_STORE *xs,
84                             X509_STORE_CTX_get_crl_fn get_crl);
85 X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(const X509_STORE_CTX *ctx);
86
87 void X509_STORE_set_check_crl(X509_STORE *xs,
88                               X509_STORE_CTX_check_crl_fn check_crl);
89 X509_STORE_CTX_check_crl_fn
90     X509_STORE_get_check_crl(const X509_STORE_CTX *ctx);
91
92 void X509_STORE_set_cert_crl(X509_STORE *xs,
93                              X509_STORE_CTX_cert_crl_fn cert_crl);
94 X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(const X509_STORE_CTX *ctx);
95
96 void X509_STORE_set_check_policy(X509_STORE *xs,
97                                  X509_STORE_CTX_check_policy_fn check_policy);
98 X509_STORE_CTX_check_policy_fn
99     X509_STORE_get_check_policy(const X509_STORE_CTX *ctx);
100
101 void X509_STORE_set_lookup_certs(X509_STORE *xs,
102                                  X509_STORE_CTX_lookup_certs_fn lookup_certs);
103 X509_STORE_CTX_lookup_certs_fn
104     X509_STORE_get_lookup_certs(const X509_STORE_CTX *ctx);
105
106 void X509_STORE_set_lookup_crls(X509_STORE *xs,
107                                 X509_STORE_CTX_lookup_crls_fn lookup_crls);
108 X509_STORE_CTX_lookup_crls_fn
109     X509_STORE_get_lookup_crls(const X509_STORE_CTX *ctx);
110
111 void X509_STORE_set_cleanup(X509_STORE *xs,
112                             X509_STORE_CTX_cleanup_fn cleanup);
113 X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(const X509_STORE_CTX *ctx);
114
115 /* Aliases */
116 void X509_STORE_set_verify_cb_func(X509_STORE *st,
117                                    X509_STORE_CTX_verify_cb verify_cb);
118 void X509_STORE_set_verify_func(X509_STORE *xs,
119                                 X509_STORE_CTX_verify_fn verify);
120 void X509_STORE_set_lookup_crls_cb(X509_STORE *xs,
121                                    X509_STORE_CTX_lookup_crls_fn lookup_crls);
122
123=head1 DESCRIPTION
124
125X509_STORE_set_verify_cb() sets the verification callback of I<xs> to
126I<verify_cb> overwriting the previous callback.
127The callback assigned with this function becomes a default for the one
128that can be assigned directly to the corresponding B<X509_STORE_CTX>,
129please see L<X509_STORE_CTX_set_verify_cb(3)> for further information.
130
131X509_STORE_set_verify() sets the final chain verification function for
132I<xs> to I<verify>.
133Its purpose is to go through the chain of certificates and check that
134all signatures are valid and that the current time is within the
135limits of each certificate's first and last validity time.
136The final chain verification functions must return 0 on failure and 1
137on success.
138I<If no chain verification function is provided, the internal default
139function will be used instead.>
140
141X509_STORE_CTX_get1_issuer() tries to find a certificate from the I<store>
142component of I<ctx> that has a subject name matching the issuer name of I<x>
143and is accepted by the I<check_issued> function in I<ctx>.
144On success it assigns to I<*issuer> the first match that has a suitable validity
145period or otherwise has the latest expiration date of all matching certificates.
146If the function returns 1 the caller is responsible for freeing I<*issuer>.
147Note that this search does not support backtracking.
148
149X509_STORE_set_get_issuer() sets the function I<get_issuer> that is used
150to get the "best" candidate issuer certificate of the given certificate I<x>.
151When such a certificate is found, I<get_issuer> must up-ref and assign it
152to I<*issuer> and then return 1.
153Otherwise I<get_issuer> must return 0 if not found and -1 (or 0) on failure.
154If X509_STORE_set_get_issuer() is not used or I<get_issuer> is NULL
155then X509_STORE_CTX_get1_issuer() is used as the default implementation.
156
157X509_STORE_set_check_issued() sets the function to check that a given
158certificate I<x> is issued by the issuer certificate I<issuer>.
159This function must return 0 on failure (among others if I<x> hasn't
160been issued with I<issuer>) and 1 on success.
161I<If no function to get the issuer is provided, the internal default
162function will be used instead.>
163
164X509_STORE_set_check_revocation() sets the revocation checking
165function.
166Its purpose is to look through the final chain and check the
167revocation status for each certificate.
168It must return 0 on failure and 1 on success.
169I<If no function to get the issuer is provided, the internal default
170function will be used instead.>
171
172X509_STORE_set_get_crl() sets the function to get the crl for a given
173certificate I<x>.
174When found, the crl must be assigned to I<*crl>.
175This function must return 0 on failure and 1 on success.
176I<If no function to get the issuer is provided, the internal default
177function will be used instead.>
178
179X509_STORE_set_check_crl() sets the function to check the validity of
180the given I<crl>.
181This function must return 0 on failure and 1 on success.
182I<If no function to get the issuer is provided, the internal default
183function will be used instead.>
184
185X509_STORE_set_cert_crl() sets the function to check the revocation
186status of the given certificate I<x> against the given I<crl>.
187This function must return 0 on failure and 1 on success.
188I<If no function to get the issuer is provided, the internal default
189function will be used instead.>
190
191X509_STORE_set_check_policy() sets the function to check the policies
192of all the certificates in the final chain..
193This function must return 0 on failure and 1 on success.
194I<If no function to get the issuer is provided, the internal default
195function will be used instead.>
196
197X509_STORE_set_lookup_certs() and X509_STORE_set_lookup_crls() set the
198functions to look up all the certs or all the CRLs that match the
199given name I<nm>.
200These functions return NULL on failure and a pointer to a stack of
201certificates (B<X509>) or to a stack of CRLs (B<X509_CRL>) on
202success.
203I<If no function to get the issuer is provided, the internal default
204function will be used instead.>
205
206X509_STORE_set_cleanup() sets the final cleanup function, which is
207called when the context (B<X509_STORE_CTX>) is being torn down.
208This function doesn't return any value.
209I<If no function to get the issuer is provided, the internal default
210function will be used instead.>
211
212X509_STORE_get_verify_cb(), X509_STORE_CTX_get_verify(),
213X509_STORE_get_get_issuer(), X509_STORE_get_check_issued(),
214X509_STORE_get_check_revocation(), X509_STORE_get_get_crl(),
215X509_STORE_get_check_crl(), X509_STORE_set_verify(),
216X509_STORE_set_get_issuer(), X509_STORE_get_cert_crl(),
217X509_STORE_get_check_policy(), X509_STORE_get_lookup_certs(),
218X509_STORE_get_lookup_crls() and X509_STORE_get_cleanup() all return
219the function pointer assigned with X509_STORE_set_check_issued(),
220X509_STORE_set_check_revocation(), X509_STORE_set_get_crl(),
221X509_STORE_set_check_crl(), X509_STORE_set_cert_crl(),
222X509_STORE_set_check_policy(), X509_STORE_set_lookup_certs(),
223X509_STORE_set_lookup_crls() and X509_STORE_set_cleanup(), or NULL if
224no assignment has been made.
225
226X509_STORE_set_verify_cb_func(), X509_STORE_set_verify_func() and
227X509_STORE_set_lookup_crls_cb() are aliases for
228X509_STORE_set_verify_cb(), X509_STORE_set_verify() and
229X509_STORE_set_lookup_crls, available as macros for backward
230compatibility.
231
232=head1 NOTES
233
234All the callbacks from a B<X509_STORE> are inherited by the
235corresponding B<X509_STORE_CTX> structure when it is initialized.
236See L<X509_STORE_CTX_set_verify_cb(3)> for further details.
237
238=head1 BUGS
239
240The macro version of this function was the only one available before
241OpenSSL 1.0.0.
242
243=head1 RETURN VALUES
244
245The X509_STORE_set_*() functions do not return a value.
246
247The X509_STORE_get_*() functions return a pointer of the appropriate
248function type.
249
250X509_STORE_CTX_get1_issuer() returns
2511 if a suitable certificate is found, 0 if not found, -1 on other error.
252
253=head1 SEE ALSO
254
255L<X509_STORE_CTX_set_verify_cb(3)>, L<X509_STORE_CTX_get0_chain(3)>,
256L<X509_STORE_CTX_verify_cb(3)>, L<X509_STORE_CTX_verify_fn(3)>,
257L<CMS_verify(3)>
258
259=head1 HISTORY
260
261The X509_STORE_set_verify_cb() function was added in OpenSSL 1.0.0.
262
263The functions
264X509_STORE_set_verify_cb(), X509_STORE_get_verify_cb(),
265X509_STORE_set_verify(), X509_STORE_CTX_get_verify(),
266X509_STORE_set_get_issuer(), X509_STORE_get_get_issuer(),
267X509_STORE_set_check_issued(), X509_STORE_get_check_issued(),
268X509_STORE_set_check_revocation(), X509_STORE_get_check_revocation(),
269X509_STORE_set_get_crl(), X509_STORE_get_get_crl(),
270X509_STORE_set_check_crl(), X509_STORE_get_check_crl(),
271X509_STORE_set_cert_crl(), X509_STORE_get_cert_crl(),
272X509_STORE_set_check_policy(), X509_STORE_get_check_policy(),
273X509_STORE_set_lookup_certs(), X509_STORE_get_lookup_certs(),
274X509_STORE_set_lookup_crls(), X509_STORE_get_lookup_crls(),
275X509_STORE_set_cleanup() and X509_STORE_get_cleanup()
276were added in OpenSSL 1.1.0.
277
278=head1 COPYRIGHT
279
280Copyright 2009-2021 The OpenSSL Project Authors. All Rights Reserved.
281
282Licensed under the Apache License 2.0 (the "License").  You may not use
283this file except in compliance with the License.  You can obtain a copy
284in the file LICENSE in the source distribution or at
285L<https://www.openssl.org/source/license.html>.
286
287=cut
288