Update copyright year
[openssl.git] / doc / man3 / X509_STORE_set_verify_cb_func.pod
1 =pod
2
3 =head1 NAME
4
5 X509_STORE_set_lookup_crls_cb,
6 X509_STORE_set_verify_func,
7 X509_STORE_get_cleanup,
8 X509_STORE_set_cleanup,
9 X509_STORE_get_lookup_crls,
10 X509_STORE_set_lookup_crls,
11 X509_STORE_get_lookup_certs,
12 X509_STORE_set_lookup_certs,
13 X509_STORE_get_check_policy,
14 X509_STORE_set_check_policy,
15 X509_STORE_get_cert_crl,
16 X509_STORE_set_cert_crl,
17 X509_STORE_get_check_crl,
18 X509_STORE_set_check_crl,
19 X509_STORE_get_get_crl,
20 X509_STORE_set_get_crl,
21 X509_STORE_get_check_revocation,
22 X509_STORE_set_check_revocation,
23 X509_STORE_get_check_issued,
24 X509_STORE_set_check_issued,
25 X509_STORE_CTX_get1_issuer,
26 X509_STORE_get_get_issuer,
27 X509_STORE_set_get_issuer,
28 X509_STORE_CTX_get_verify,
29 X509_STORE_set_verify,
30 X509_STORE_get_verify_cb,
31 X509_STORE_set_verify_cb_func, X509_STORE_set_verify_cb,
32 X509_STORE_CTX_cert_crl_fn, X509_STORE_CTX_check_crl_fn,
33 X509_STORE_CTX_check_issued_fn, X509_STORE_CTX_check_policy_fn,
34 X509_STORE_CTX_check_revocation_fn, X509_STORE_CTX_cleanup_fn,
35 X509_STORE_CTX_get_crl_fn, X509_STORE_CTX_get_issuer_fn,
36 X509_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 *ctx,
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 *ctx, 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 *ctx,
71                                 X509_STORE_CTX_get_issuer_fn get_issuer);
72
73  void X509_STORE_set_check_issued(X509_STORE *ctx,
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 *ctx,
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 *ctx,
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 *ctx,
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 *ctx,
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 *ctx,
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 *ctx,
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 *ctx,
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 *ctx,
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 *ctx,
119                                  X509_STORE_CTX_verify_fn verify);
120  void X509_STORE_set_lookup_crls_cb(X509_STORE *ctx,
121                                     X509_STORE_CTX_lookup_crls_fn lookup_crls);
122
123 =head1 DESCRIPTION
124
125 X509_STORE_set_verify_cb() sets the verification callback of I<ctx> to
126 I<verify_cb> overwriting the previous callback.
127 The callback assigned with this function becomes a default for the one
128 that can be assigned directly to the corresponding B<X509_STORE_CTX>,
129 please see L<X509_STORE_CTX_set_verify_cb(3)> for further information.
130
131 X509_STORE_set_verify() sets the final chain verification function for
132 I<ctx> to I<verify>.
133 Its purpose is to go through the chain of certificates and check that
134 all signatures are valid and that the current time is within the
135 limits of each certificate's first and last validity time.
136 The final chain verification functions must return 0 on failure and 1
137 on success.
138 I<If no chain verification function is provided, the internal default
139 function will be used instead.>
140
141 X509_STORE_CTX_get1_issuer() tries to find a certificate from the I<store>
142 component of I<ctx> with a subject name matching the issuer name of I<x>.
143 On success it assigns to I<*issuer> the first match that is currently valid,
144 or at least the most recently expired match if there is no currently valid one.
145 If the function returns 1 the caller is responsible for freeing I<*issuer>.
146
147 X509_STORE_set_get_issuer() sets the function I<get_issuer>
148 to get the "best" candidate issuer certificate of the given certificate I<x>.
149 When such a certificate is found, I<get_issuer> must up-ref and assign it
150 to I<*issuer> and then return 1.
151 Otherwise I<get_issuer> must return 0 if not found and -1 (or 0) on failure.
152 If X509_STORE_set_get_issuer() is not used or I<get_issuer> is NULL
153 then X509_STORE_CTX_get1_issuer() is used as the default implementation.
154
155 X509_STORE_set_check_issued() sets the function to check that a given
156 certificate I<x> is issued by the issuer certificate I<issuer>.
157 This function must return 0 on failure (among others if I<x> hasn't
158 been issued with I<issuer>) and 1 on success.
159 I<If no function to get the issuer is provided, the internal default
160 function will be used instead.>
161
162 X509_STORE_set_check_revocation() sets the revocation checking
163 function.
164 Its purpose is to look through the final chain and check the
165 revocation status for each certificate.
166 It must return 0 on failure and 1 on success.
167 I<If no function to get the issuer is provided, the internal default
168 function will be used instead.>
169
170 X509_STORE_set_get_crl() sets the function to get the crl for a given
171 certificate I<x>.
172 When found, the crl must be assigned to I<*crl>.
173 This function must return 0 on failure and 1 on success.
174 I<If no function to get the issuer is provided, the internal default
175 function will be used instead.>
176
177 X509_STORE_set_check_crl() sets the function to check the validity of
178 the given I<crl>.
179 This function must return 0 on failure and 1 on success.
180 I<If no function to get the issuer is provided, the internal default
181 function will be used instead.>
182
183 X509_STORE_set_cert_crl() sets the function to check the revocation
184 status of the given certificate I<x> against the given I<crl>.
185 This function must return 0 on failure and 1 on success.
186 I<If no function to get the issuer is provided, the internal default
187 function will be used instead.>
188
189 X509_STORE_set_check_policy() sets the function to check the policies
190 of all the certificates in the final chain..
191 This function must return 0 on failure and 1 on success.
192 I<If no function to get the issuer is provided, the internal default
193 function will be used instead.>
194
195 X509_STORE_set_lookup_certs() and X509_STORE_set_lookup_crls() set the
196 functions to look up all the certs or all the CRLs that match the
197 given name I<nm>.
198 These functions return NULL on failure and a pointer to a stack of
199 certificates (B<X509>) or to a stack of CRLs (B<X509_CRL>) on
200 success.
201 I<If no function to get the issuer is provided, the internal default
202 function will be used instead.>
203
204 X509_STORE_set_cleanup() sets the final cleanup function, which is
205 called when the context (B<X509_STORE_CTX>) is being torn down.
206 This function doesn't return any value.
207 I<If no function to get the issuer is provided, the internal default
208 function will be used instead.>
209
210 X509_STORE_get_verify_cb(), X509_STORE_CTX_get_verify(),
211 X509_STORE_get_get_issuer(), X509_STORE_get_check_issued(),
212 X509_STORE_get_check_revocation(), X509_STORE_get_get_crl(),
213 X509_STORE_get_check_crl(), X509_STORE_set_verify(),
214 X509_STORE_set_get_issuer(), X509_STORE_get_cert_crl(),
215 X509_STORE_get_check_policy(), X509_STORE_get_lookup_certs(),
216 X509_STORE_get_lookup_crls() and X509_STORE_get_cleanup() all return
217 the function pointer assigned with X509_STORE_set_check_issued(),
218 X509_STORE_set_check_revocation(), X509_STORE_set_get_crl(),
219 X509_STORE_set_check_crl(), X509_STORE_set_cert_crl(),
220 X509_STORE_set_check_policy(), X509_STORE_set_lookup_certs(),
221 X509_STORE_set_lookup_crls() and X509_STORE_set_cleanup(), or NULL if
222 no assignment has been made.
223
224 X509_STORE_set_verify_cb_func(), X509_STORE_set_verify_func() and
225 X509_STORE_set_lookup_crls_cb() are aliases for
226 X509_STORE_set_verify_cb(), X509_STORE_set_verify() and
227 X509_STORE_set_lookup_crls, available as macros for backward
228 compatibility.
229
230 =head1 NOTES
231
232 All the callbacks from a B<X509_STORE> are inherited by the
233 corresponding B<X509_STORE_CTX> structure when it is initialized.
234 See L<X509_STORE_CTX_set_verify_cb(3)> for further details.
235
236 =head1 BUGS
237
238 The macro version of this function was the only one available before
239 OpenSSL 1.0.0.
240
241 =head1 RETURN VALUES
242
243 The X509_STORE_set_*() functions do not return a value.
244
245 The X509_STORE_get_*() functions return a pointer of the appropriate
246 function type.
247
248 X509_STORE_CTX_get1_issuer() returns
249 1 if a suitable certificate is found, 0 if not found, -1 on other error.
250
251 =head1 SEE ALSO
252
253 L<X509_STORE_CTX_set_verify_cb(3)>, L<X509_STORE_CTX_get0_chain(3)>,
254 L<X509_STORE_CTX_verify_cb(3)>, L<X509_STORE_CTX_verify_fn(3)>,
255 L<CMS_verify(3)>
256
257 =head1 HISTORY
258
259 The X509_STORE_set_verify_cb() function was added in OpenSSL 1.0.0.
260
261 The functions
262 X509_STORE_set_verify_cb(), X509_STORE_get_verify_cb(),
263 X509_STORE_set_verify(), X509_STORE_CTX_get_verify(),
264 X509_STORE_set_get_issuer(), X509_STORE_get_get_issuer(),
265 X509_STORE_set_check_issued(), X509_STORE_get_check_issued(),
266 X509_STORE_set_check_revocation(), X509_STORE_get_check_revocation(),
267 X509_STORE_set_get_crl(), X509_STORE_get_get_crl(),
268 X509_STORE_set_check_crl(), X509_STORE_get_check_crl(),
269 X509_STORE_set_cert_crl(), X509_STORE_get_cert_crl(),
270 X509_STORE_set_check_policy(), X509_STORE_get_check_policy(),
271 X509_STORE_set_lookup_certs(), X509_STORE_get_lookup_certs(),
272 X509_STORE_set_lookup_crls(), X509_STORE_get_lookup_crls(),
273 X509_STORE_set_cleanup() and X509_STORE_get_cleanup()
274 were added in OpenSSL 1.1.0.
275
276 =head1 COPYRIGHT
277
278 Copyright 2009-2021 The OpenSSL Project Authors. All Rights Reserved.
279
280 Licensed under the Apache License 2.0 (the "License").  You may not use
281 this file except in compliance with the License.  You can obtain a copy
282 in the file LICENSE in the source distribution or at
283 L<https://www.openssl.org/source/license.html>.
284
285 =cut