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