]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/X509_STORE_CTX_new.pod
Expand the XTS documentation
[thirdparty/openssl.git] / doc / man3 / X509_STORE_CTX_new.pod
CommitLineData
db576632
DSH
1=pod
2
3=head1 NAME
4
f0e0fd51
RS
5X509_STORE_CTX_new, X509_STORE_CTX_cleanup, X509_STORE_CTX_free,
6X509_STORE_CTX_init, X509_STORE_CTX_set0_trusted_stack, X509_STORE_CTX_set_cert,
7X509_STORE_CTX_set0_crls,
8X509_STORE_CTX_get0_chain, X509_STORE_CTX_set0_verified_chain,
9X509_STORE_CTX_get0_param, X509_STORE_CTX_set0_param,
4dba585f 10X509_STORE_CTX_get0_untrusted, X509_STORE_CTX_set0_untrusted,
f0e0fd51
RS
11X509_STORE_CTX_get_num_untrusted,
12X509_STORE_CTX_set_default,
121677b4
RS
13X509_STORE_CTX_set_verify,
14X509_STORE_CTX_verify_fn
99d63d46 15- X509_STORE_CTX initialisation
db576632
DSH
16
17=head1 SYNOPSIS
18
19 #include <openssl/x509_vfy.h>
20
21 X509_STORE_CTX *X509_STORE_CTX_new(void);
22 void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
23 void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
24
25 int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
1bc74519 26 X509 *x509, STACK_OF(X509) *chain);
db576632 27
f0e0fd51 28 void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
db576632 29
aebb9aac 30 void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x);
8cc86b81 31 STACK_OF(X509) *X509_STORE_CTX_get0_chain(const X509_STORE_CTX *ctx);
f0e0fd51
RS
32 void X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *chain);
33 void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk);
db576632 34
8cc86b81 35 X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(const X509_STORE_CTX *ctx);
db576632
DSH
36 void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);
37 int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);
38
8cc86b81 39 STACK_OF(X509)* X509_STORE_CTX_get0_untrusted(const X509_STORE_CTX *ctx);
4dba585f 40 void X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
f0e0fd51 41
8cc86b81 42 int X509_STORE_CTX_get_num_untrusted(const X509_STORE_CTX *ctx);
7f3f41d8 43
4a7b3a7b 44 typedef int (*X509_STORE_CTX_verify_fn)(X509_STORE_CTX *);
4a7b3a7b 45 void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx, X509_STORE_CTX_verify_fn verify);
f0e0fd51 46
db576632
DSH
47=head1 DESCRIPTION
48
49These functions initialise an B<X509_STORE_CTX> structure for subsequent use
50by X509_verify_cert().
51
52X509_STORE_CTX_new() returns a newly initialised B<X509_STORE_CTX> structure.
53
54X509_STORE_CTX_cleanup() internally cleans up an B<X509_STORE_CTX> structure.
55The context can then be reused with an new call to X509_STORE_CTX_init().
56
57X509_STORE_CTX_free() completely frees up B<ctx>. After this call B<ctx>
58is no longer valid.
222561fe 59If B<ctx> is NULL nothing is done.
db576632
DSH
60
61X509_STORE_CTX_init() sets up B<ctx> for a subsequent verification operation.
aae41f8c
MC
62It must be called before each call to X509_verify_cert(), i.e. a B<ctx> is only
63good for one call to X509_verify_cert(); if you want to verify a second
7643a172 64certificate with the same B<ctx> then you must call X509_STORE_CTX_cleanup()
aae41f8c
MC
65and then X509_STORE_CTX_init() again before the second call to
66X509_verify_cert(). The trusted certificate store is set to B<store>, the end
67entity certificate to be verified is set to B<x509> and a set of additional
68certificates (which will be untrusted but may be used to build the chain) in
69B<chain>. Any or all of the B<store>, B<x509> and B<chain> parameters can be
70B<NULL>.
db576632 71
f0e0fd51
RS
72X509_STORE_CTX_set0_trusted_stack() sets the set of trusted certificates of
73B<ctx> to B<sk>. This is an alternative way of specifying trusted certificates
db576632
DSH
74instead of using an B<X509_STORE>.
75
186bb907 76X509_STORE_CTX_set_cert() sets the certificate to be verified in B<ctx> to
db576632
DSH
77B<x>.
78
f0e0fd51
RS
79X509_STORE_CTX_set0_verified_chain() sets the validated chain used
80by B<ctx> to be B<chain>.
81Ownership of the chain is transferred to B<ctx> and should not be
82free'd by the caller.
83X509_STORE_CTX_get0_chain() returns a the internal pointer used by the
84B<ctx> that contains the validated chain.
db576632
DSH
85
86X509_STORE_CTX_set0_crls() sets a set of CRLs to use to aid certificate
87verification to B<sk>. These CRLs will only be used if CRL verification is
88enabled in the associated B<X509_VERIFY_PARAM> structure. This might be
89used where additional "useful" CRLs are supplied as part of a protocol,
90for example in a PKCS#7 structure.
91
f0e0fd51 92X509_STORE_CTX_get0_param() retrieves an internal pointer
db576632
DSH
93to the verification parameters associated with B<ctx>.
94
f0e0fd51 95X509_STORE_CTX_get0_untrusted() retrieves an internal pointer to the
0ad69cd6 96stack of untrusted certificates associated with B<ctx>.
f0e0fd51 97
4dba585f 98X509_STORE_CTX_set0_untrusted() sets the internal point to the stack
0ad69cd6 99of untrusted certificates associated with B<ctx> to B<sk>.
4dba585f 100
186bb907 101X509_STORE_CTX_set0_param() sets the internal verification parameter pointer
db576632
DSH
102to B<param>. After this call B<param> should not be used.
103
104X509_STORE_CTX_set_default() looks up and sets the default verification
105method to B<name>. This uses the function X509_VERIFY_PARAM_lookup() to
106find an appropriate set of parameters from B<name>.
107
7f3f41d8
MC
108X509_STORE_CTX_get_num_untrusted() returns the number of untrusted certificates
109that were used in building the chain following a call to X509_verify_cert().
110
7cafbb4b
MC
111X509_STORE_CTX_set_verify() provides the capability for overriding the default
112verify function. This function is responsible for verifying chain signatures and
99d63d46 113expiration times.
7cafbb4b
MC
114
115A verify function is defined as an X509_STORE_CTX_verify type which has the
116following signature:
117
1bc74519 118 int (*verify)(X509_STORE_CTX *);
7cafbb4b
MC
119
120This function should receive the current X509_STORE_CTX as a parameter and
121return 1 on success or 0 on failure.
122
db576632
DSH
123=head1 NOTES
124
125The certificates and CRLs in a store are used internally and should B<not>
f0e0fd51 126be freed up until after the associated B<X509_STORE_CTX> is freed.
db576632
DSH
127
128=head1 BUGS
129
130The certificates and CRLs in a context are used internally and should B<not>
131be freed up until after the associated B<X509_STORE_CTX> is freed. Copies
132should be made or reference counts increased instead.
133
134=head1 RETURN VALUES
135
136X509_STORE_CTX_new() returns an newly allocates context or B<NULL> is an
137error occurred.
138
139X509_STORE_CTX_init() returns 1 for success or 0 if an error occurred.
140
141X509_STORE_CTX_get0_param() returns a pointer to an B<X509_VERIFY_PARAM>
142structure or B<NULL> if an error occurred.
143
f0e0fd51
RS
144X509_STORE_CTX_cleanup(), X509_STORE_CTX_free(),
145X509_STORE_CTX_set0_trusted_stack(),
146X509_STORE_CTX_set_cert(),
db576632
DSH
147X509_STORE_CTX_set0_crls() and X509_STORE_CTX_set0_param() do not return
148values.
149
150X509_STORE_CTX_set_default() returns 1 for success or 0 if an error occurred.
151
7f3f41d8
MC
152X509_STORE_CTX_get_num_untrusted() returns the number of untrusted certificates
153used.
154
db576632
DSH
155=head1 SEE ALSO
156
9b86974e
RS
157L<X509_verify_cert(3)>
158L<X509_VERIFY_PARAM_set_flags(3)>
db576632
DSH
159
160=head1 HISTORY
161
fc5ecadd
DMSP
162The X509_STORE_CTX_set0_crls() function was added in OpenSSL 1.0.0.
163The X509_STORE_CTX_get_num_untrusted() function was added in OpenSSL 1.1.0.
db576632 164
e2f92610
RS
165=head1 COPYRIGHT
166
167Copyright 2009-2016 The OpenSSL Project Authors. All Rights Reserved.
168
4746f25a 169Licensed under the Apache License 2.0 (the "License"). You may not use
e2f92610
RS
170this file except in compliance with the License. You can obtain a copy
171in the file LICENSE in the source distribution or at
172L<https://www.openssl.org/source/license.html>.
173
174=cut