5 X509_STORE_CTX_new, X509_STORE_CTX_cleanup, X509_STORE_CTX_free,
6 X509_STORE_CTX_init, X509_STORE_CTX_set0_trusted_stack, X509_STORE_CTX_set_cert,
7 X509_STORE_CTX_set0_crls,
8 X509_STORE_CTX_get0_chain, X509_STORE_CTX_set0_verified_chain,
9 X509_STORE_CTX_get0_param, X509_STORE_CTX_set0_param,
10 X509_STORE_CTX_get0_untrusted, X509_STORE_CTX_set0_untrusted,
11 X509_STORE_CTX_get_num_untrusted,
12 X509_STORE_CTX_set_default,
13 X509_STORE_CTX_set_verify,
14 X509_STORE_CTX_get_verify - X509_STORE_CTX initialisation
18 #include <openssl/x509_vfy.h>
20 X509_STORE_CTX *X509_STORE_CTX_new(void);
21 void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
22 void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
24 int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
25 X509 *x509, STACK_OF(X509) *chain);
27 void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
29 void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx,X509 *x);
30 STACK_OF(X509) *X509_STORE_CTX_get0_chain(X609_STORE_CTX *ctx);
31 void X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *chain);
32 void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk);
34 X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);
35 void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);
36 int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);
38 STACK_OF(X509)* X509_STORE_CTX_get0_untrusted(X509_STORE_CTX *ctx);
39 void X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
41 int X509_STORE_CTX_get_num_untrusted(X509_STORE_CTX *ctx);
43 typedef int (*X509_STORE_CTX_verify)(X509_STORE_CTX *);
44 X509_STORE_CTX_verify X509_STORE_CTX_get_verify(X509_STORE_CTX *ctx);
45 void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx, X509_STORE_CTX_verify verify);
47 void X509_STORE_set_verify(X509_STORE *ctx, X509_STORE_CTX_verify verify);
51 These functions initialise an B<X509_STORE_CTX> structure for subsequent use
52 by X509_verify_cert().
54 X509_STORE_CTX_new() returns a newly initialised B<X509_STORE_CTX> structure.
56 X509_STORE_CTX_cleanup() internally cleans up an B<X509_STORE_CTX> structure.
57 The context can then be reused with an new call to X509_STORE_CTX_init().
59 X509_STORE_CTX_free() completely frees up B<ctx>. After this call B<ctx>
61 If B<ctx> is NULL nothing is done.
63 X509_STORE_CTX_init() sets up B<ctx> for a subsequent verification operation.
64 It must be called before each call to X509_verify_cert(), i.e. a B<ctx> is only
65 good for one call to X509_verify_cert(); if you want to verify a second
66 certificate with the same B<ctx> then you must call X509_XTORE_CTX_cleanup()
67 and then X509_STORE_CTX_init() again before the second call to
68 X509_verify_cert(). The trusted certificate store is set to B<store>, the end
69 entity certificate to be verified is set to B<x509> and a set of additional
70 certificates (which will be untrusted but may be used to build the chain) in
71 B<chain>. Any or all of the B<store>, B<x509> and B<chain> parameters can be
74 X509_STORE_CTX_set0_trusted_stack() sets the set of trusted certificates of
75 B<ctx> to B<sk>. This is an alternative way of specifying trusted certificates
76 instead of using an B<X509_STORE>.
78 X509_STORE_CTX_set_cert() sets the certificate to be verified in B<ctx> to
81 X509_STORE_CTX_set0_verified_chain() sets the validated chain used
82 by B<ctx> to be B<chain>.
83 Ownership of the chain is transferred to B<ctx> and should not be
85 X509_STORE_CTX_get0_chain() returns a the internal pointer used by the
86 B<ctx> that contains the validated chain.
88 X509_STORE_CTX_set0_crls() sets a set of CRLs to use to aid certificate
89 verification to B<sk>. These CRLs will only be used if CRL verification is
90 enabled in the associated B<X509_VERIFY_PARAM> structure. This might be
91 used where additional "useful" CRLs are supplied as part of a protocol,
92 for example in a PKCS#7 structure.
94 X509_STORE_CTX_get0_param() retrieves an internal pointer
95 to the verification parameters associated with B<ctx>.
97 X509_STORE_CTX_get0_untrusted() retrieves an internal pointer to the
98 stack of untrusted certificates associated with B<ctx>.
100 X509_STORE_CTX_set0_untrusted() sets the internal point to the stack
101 of untrusted certificates associated with B<ctx> to B<sk>.
103 X509_STORE_CTX_set0_param() sets the internal verification parameter pointer
104 to B<param>. After this call B<param> should not be used.
106 X509_STORE_CTX_set_default() looks up and sets the default verification
107 method to B<name>. This uses the function X509_VERIFY_PARAM_lookup() to
108 find an appropriate set of parameters from B<name>.
110 X509_STORE_CTX_get_num_untrusted() returns the number of untrusted certificates
111 that were used in building the chain following a call to X509_verify_cert().
113 X509_STORE_CTX_set_verify() provides the capability for overriding the default
114 verify function. This function is responsible for verifying chain signatures and
115 expiration times. X509_STORE_CTX_get_verify() obtains the current verify
118 X509_STORE_set_verify() works in the same way as for X509_STORE_CTX_set_verify()
119 but sets the default verify function to be used by all X509_STORE_CTX objects
120 created for this X509_STORE.
122 A verify function is defined as an X509_STORE_CTX_verify type which has the
125 int (*verify)(X509_STORE_CTX *);
127 This function should receive the current X509_STORE_CTX as a parameter and
128 return 1 on success or 0 on failure.
132 The certificates and CRLs in a store are used internally and should B<not>
133 be freed up until after the associated B<X509_STORE_CTX> is freed.
137 The certificates and CRLs in a context are used internally and should B<not>
138 be freed up until after the associated B<X509_STORE_CTX> is freed. Copies
139 should be made or reference counts increased instead.
143 X509_STORE_CTX_new() returns an newly allocates context or B<NULL> is an
146 X509_STORE_CTX_init() returns 1 for success or 0 if an error occurred.
148 X509_STORE_CTX_get0_param() returns a pointer to an B<X509_VERIFY_PARAM>
149 structure or B<NULL> if an error occurred.
151 X509_STORE_CTX_cleanup(), X509_STORE_CTX_free(),
152 X509_STORE_CTX_set0_trusted_stack(),
153 X509_STORE_CTX_set_cert(),
154 X509_STORE_CTX_set0_crls() and X509_STORE_CTX_set0_param() do not return
157 X509_STORE_CTX_set_default() returns 1 for success or 0 if an error occurred.
159 X509_STORE_CTX_get_num_untrusted() returns the number of untrusted certificates
162 X509_STORE_CTX_get_verify() returns the current verify function in use for this
167 L<X509_verify_cert(3)>
168 L<X509_VERIFY_PARAM_set_flags(3)>
172 X509_STORE_CTX_set0_crls() was first added to OpenSSL 1.0.0
173 X509_STORE_CTX_get_num_untrusted() was first added to OpenSSL 1.1.0
174 X509_STORE_set_verify() was first added to OpenSSL 1.1.0. It was previously
175 available as a macro X509_STORE_set_verify_func(). This macro still exists but
176 simply calls this function.
180 Copyright 2009-2016 The OpenSSL Project Authors. All Rights Reserved.
182 Licensed under the OpenSSL license (the "License"). You may not use
183 this file except in compliance with the License. You can obtain a copy
184 in the file LICENSE in the source distribution or at
185 L<https://www.openssl.org/source/license.html>.