5 X509_STORE_CTX_new_with_libctx, X509_STORE_CTX_new, X509_STORE_CTX_cleanup,
6 X509_STORE_CTX_free, X509_STORE_CTX_init, X509_STORE_CTX_set0_trusted_stack,
7 X509_STORE_CTX_set_cert, 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_verify_fn
15 - X509_STORE_CTX initialisation
19 #include <openssl/x509_vfy.h>
21 X509_STORE_CTX *X509_STORE_CTX_new_with_libctx(OPENSSL_CTX *libctx,
23 X509_STORE_CTX *X509_STORE_CTX_new(void);
24 void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
25 void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
27 int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
28 X509 *x509, STACK_OF(X509) *chain);
30 void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
32 void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x);
33 STACK_OF(X509) *X509_STORE_CTX_get0_chain(const X509_STORE_CTX *ctx);
34 void X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *chain);
35 void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk);
37 X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(const X509_STORE_CTX *ctx);
38 void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);
39 int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);
41 STACK_OF(X509)* X509_STORE_CTX_get0_untrusted(const X509_STORE_CTX *ctx);
42 void X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
44 int X509_STORE_CTX_get_num_untrusted(const X509_STORE_CTX *ctx);
46 typedef int (*X509_STORE_CTX_verify_fn)(X509_STORE_CTX *);
47 void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx, X509_STORE_CTX_verify_fn verify);
51 These functions initialise an B<X509_STORE_CTX> structure for subsequent use
52 by X509_verify_cert().
54 X509_STORE_CTX_new_with_libctx() returns a newly initialised B<X509_STORE_CTX>
55 structure associated with the specified library context I<libctx> and property
56 query string I<propq>. Any cryptographic algorithms fetched while performing
57 processing with the X509_STORE_CTX will use that library context and property
60 X509_STORE_CTX_new() is the same as X509_STORE_CTX_new_with_libctx() except that
61 the default library context and a NULL property query string are used.
63 X509_STORE_CTX_cleanup() internally cleans up an B<X509_STORE_CTX> structure.
64 The context can then be reused with an new call to X509_STORE_CTX_init().
66 X509_STORE_CTX_free() completely frees up I<ctx>. After this call I<ctx>
68 If I<ctx> is NULL nothing is done.
70 X509_STORE_CTX_init() sets up I<ctx> for a subsequent verification operation.
71 It must be called before each call to X509_verify_cert(), i.e. a I<ctx> is only
72 good for one call to X509_verify_cert(); if you want to verify a second
73 certificate with the same I<ctx> then you must call X509_STORE_CTX_cleanup()
74 and then X509_STORE_CTX_init() again before the second call to
75 X509_verify_cert(). The trusted certificate store is set to I<store>, the end
76 entity certificate to be verified is set to I<x509> and a set of additional
77 certificates (which will be untrusted but may be used to build the chain) in
78 I<chain>. Any or all of the I<store>, I<x509> and I<chain> parameters can be
81 X509_STORE_CTX_set0_trusted_stack() sets the set of trusted certificates of
82 I<ctx> to I<sk>. This is an alternative way of specifying trusted certificates
83 instead of using an B<X509_STORE>.
85 X509_STORE_CTX_set_cert() sets the certificate to be verified in I<ctx> to
88 X509_STORE_CTX_set0_verified_chain() sets the validated chain used
89 by I<ctx> to be I<chain>.
90 Ownership of the chain is transferred to I<ctx> and should not be
92 X509_STORE_CTX_get0_chain() returns a the internal pointer used by the
93 I<ctx> that contains the validated chain.
95 X509_STORE_CTX_set0_crls() sets a set of CRLs to use to aid certificate
96 verification to I<sk>. These CRLs will only be used if CRL verification is
97 enabled in the associated B<X509_VERIFY_PARAM> structure. This might be
98 used where additional "useful" CRLs are supplied as part of a protocol,
99 for example in a PKCS#7 structure.
101 X509_STORE_CTX_get0_param() retrieves an internal pointer
102 to the verification parameters associated with I<ctx>.
104 X509_STORE_CTX_get0_untrusted() retrieves an internal pointer to the
105 stack of untrusted certificates associated with I<ctx>.
107 X509_STORE_CTX_set0_untrusted() sets the internal point to the stack
108 of untrusted certificates associated with I<ctx> to I<sk>.
110 X509_STORE_CTX_set0_param() sets the internal verification parameter pointer
111 to I<param>. After this call B<param> should not be used.
113 X509_STORE_CTX_set_default() looks up and sets the default verification
114 method to I<name>. This uses the function X509_VERIFY_PARAM_lookup() to
115 find an appropriate set of parameters from I<name>.
117 X509_STORE_CTX_get_num_untrusted() returns the number of untrusted certificates
118 that were used in building the chain following a call to X509_verify_cert().
120 X509_STORE_CTX_set_verify() provides the capability for overriding the default
121 verify function. This function is responsible for verifying chain signatures and
124 A verify function is defined as an X509_STORE_CTX_verify type which has the
127 int (*verify)(X509_STORE_CTX *);
129 This function should receive the current X509_STORE_CTX as a parameter and
130 return 1 on success or 0 on failure.
134 The certificates and CRLs in a store are used internally and should B<not>
135 be freed up until after the associated B<X509_STORE_CTX> is freed.
139 The certificates and CRLs in a context are used internally and should B<not>
140 be freed up until after the associated B<X509_STORE_CTX> is freed. Copies
141 should be made or reference counts increased instead.
145 X509_STORE_CTX_new() returns an newly allocates context or B<NULL> is an
148 X509_STORE_CTX_init() returns 1 for success or 0 if an error occurred.
150 X509_STORE_CTX_get0_param() returns a pointer to an B<X509_VERIFY_PARAM>
151 structure or B<NULL> if an error occurred.
153 X509_STORE_CTX_cleanup(), X509_STORE_CTX_free(),
154 X509_STORE_CTX_set0_trusted_stack(),
155 X509_STORE_CTX_set_cert(),
156 X509_STORE_CTX_set0_crls() and X509_STORE_CTX_set0_param() do not return
159 X509_STORE_CTX_set_default() returns 1 for success or 0 if an error occurred.
161 X509_STORE_CTX_get_num_untrusted() returns the number of untrusted certificates
166 L<X509_verify_cert(3)>
167 L<X509_VERIFY_PARAM_set_flags(3)>
171 The X509_STORE_CTX_set0_crls() function was added in OpenSSL 1.0.0.
172 The X509_STORE_CTX_get_num_untrusted() function was added in OpenSSL 1.1.0.
173 The X509_STORE_CTX_new_with_libctx() function was added in OpenSSL 3.0.
177 Copyright 2009-2016 The OpenSSL Project Authors. All Rights Reserved.
179 Licensed under the Apache License 2.0 (the "License"). You may not use
180 this file except in compliance with the License. You can obtain a copy
181 in the file LICENSE in the source distribution or at
182 L<https://www.openssl.org/source/license.html>.