]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/crypto/X509_STORE_CTX_new.pod
Add checks to X509_NAME_oneline()
[thirdparty/openssl.git] / doc / crypto / 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,
10X509_STORE_CTX_get0_cert,
4dba585f 11X509_STORE_CTX_get0_untrusted, X509_STORE_CTX_set0_untrusted,
f0e0fd51
RS
12X509_STORE_CTX_get_num_untrusted,
13X509_STORE_CTX_set_default,
14X509_STORE_CTX_get_verify_cb,
15X509_STORE_CTX_set_verify,
16X509_STORE_CTX_get_verify - X509_STORE_CTX initialisation
db576632
DSH
17
18=head1 SYNOPSIS
19
20 #include <openssl/x509_vfy.h>
21
22 X509_STORE_CTX *X509_STORE_CTX_new(void);
23 void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
24 void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
25
26 int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
27 X509 *x509, STACK_OF(X509) *chain);
28
f0e0fd51 29 void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
db576632 30
f0e0fd51
RS
31 void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx,X509 *x);
32 STACK_OF(X509) *X509_STORE_CTX_get0_chain(X609_STORE_CTX *ctx);
33 void X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *chain);
34 void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk);
db576632
DSH
35
36 X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);
37 void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);
38 int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);
39
f0e0fd51
RS
40 X509 *X509_STORE_CTX_get0_cert(X509_STORE_CTX *ctx);
41 STACK_OF(X509)* X509_STORE_CTX_get0_untrusted(X509_STORE_CTX *ctx);
4dba585f 42 void X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
f0e0fd51 43
7f3f41d8
MC
44 int X509_STORE_CTX_get_num_untrusted(X509_STORE_CTX *ctx);
45
f0e0fd51
RS
46 typedef int (*X509_STORE_CTX_verify)(X509_STORE_CTX *);
47 X509_STORE_CTX_verify X509_STORE_CTX_get_verify(X509_STORE_CTX *ctx);
48 void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx, X509_STORE_CTX_verify verify);
49
50
db576632
DSH
51=head1 DESCRIPTION
52
53These functions initialise an B<X509_STORE_CTX> structure for subsequent use
54by X509_verify_cert().
55
56X509_STORE_CTX_new() returns a newly initialised B<X509_STORE_CTX> structure.
57
58X509_STORE_CTX_cleanup() internally cleans up an B<X509_STORE_CTX> structure.
59The context can then be reused with an new call to X509_STORE_CTX_init().
60
61X509_STORE_CTX_free() completely frees up B<ctx>. After this call B<ctx>
62is no longer valid.
222561fe 63If B<ctx> is NULL nothing is done.
db576632
DSH
64
65X509_STORE_CTX_init() sets up B<ctx> for a subsequent verification operation.
aae41f8c
MC
66It must be called before each call to X509_verify_cert(), i.e. a B<ctx> is only
67good for one call to X509_verify_cert(); if you want to verify a second
68certificate with the same B<ctx> then you must call X509_XTORE_CTX_cleanup()
69and then X509_STORE_CTX_init() again before the second call to
70X509_verify_cert(). The trusted certificate store is set to B<store>, the end
71entity certificate to be verified is set to B<x509> and a set of additional
72certificates (which will be untrusted but may be used to build the chain) in
73B<chain>. Any or all of the B<store>, B<x509> and B<chain> parameters can be
74B<NULL>.
db576632 75
f0e0fd51
RS
76X509_STORE_CTX_set0_trusted_stack() sets the set of trusted certificates of
77B<ctx> to B<sk>. This is an alternative way of specifying trusted certificates
db576632
DSH
78instead of using an B<X509_STORE>.
79
186bb907 80X509_STORE_CTX_set_cert() sets the certificate to be verified in B<ctx> to
db576632
DSH
81B<x>.
82
f0e0fd51
RS
83X509_STORE_CTX_set0_verified_chain() sets the validated chain used
84by B<ctx> to be B<chain>.
85Ownership of the chain is transferred to B<ctx> and should not be
86free'd by the caller.
87X509_STORE_CTX_get0_chain() returns a the internal pointer used by the
88B<ctx> that contains the validated chain.
db576632
DSH
89
90X509_STORE_CTX_set0_crls() sets a set of CRLs to use to aid certificate
91verification to B<sk>. These CRLs will only be used if CRL verification is
92enabled in the associated B<X509_VERIFY_PARAM> structure. This might be
93used where additional "useful" CRLs are supplied as part of a protocol,
94for example in a PKCS#7 structure.
95
f0e0fd51 96X509_STORE_CTX_get0_param() retrieves an internal pointer
db576632
DSH
97to the verification parameters associated with B<ctx>.
98
f0e0fd51
RS
99X509_STORE_CTX_get0_cert() retrieves an internal pointer to the
100certificate being verified by the B<ctx>.
101
102X509_STORE_CTX_get0_untrusted() retrieves an internal pointer to the
103stack of untrusted certifieds associated with B<ctx>.
104
4dba585f
DSH
105X509_STORE_CTX_set0_untrusted() sets the internal point to the stack
106of unstrusted certificates associated with B<ctx> to B<sk>.
107
186bb907 108X509_STORE_CTX_set0_param() sets the internal verification parameter pointer
db576632
DSH
109to B<param>. After this call B<param> should not be used.
110
111X509_STORE_CTX_set_default() looks up and sets the default verification
112method to B<name>. This uses the function X509_VERIFY_PARAM_lookup() to
113find an appropriate set of parameters from B<name>.
114
7f3f41d8
MC
115X509_STORE_CTX_get_num_untrusted() returns the number of untrusted certificates
116that were used in building the chain following a call to X509_verify_cert().
117
db576632
DSH
118=head1 NOTES
119
120The certificates and CRLs in a store are used internally and should B<not>
f0e0fd51 121be freed up until after the associated B<X509_STORE_CTX> is freed.
db576632
DSH
122
123=head1 BUGS
124
125The certificates and CRLs in a context are used internally and should B<not>
126be freed up until after the associated B<X509_STORE_CTX> is freed. Copies
127should be made or reference counts increased instead.
128
129=head1 RETURN VALUES
130
131X509_STORE_CTX_new() returns an newly allocates context or B<NULL> is an
132error occurred.
133
134X509_STORE_CTX_init() returns 1 for success or 0 if an error occurred.
135
136X509_STORE_CTX_get0_param() returns a pointer to an B<X509_VERIFY_PARAM>
137structure or B<NULL> if an error occurred.
138
f0e0fd51
RS
139X509_STORE_CTX_cleanup(), X509_STORE_CTX_free(),
140X509_STORE_CTX_set0_trusted_stack(),
141X509_STORE_CTX_set_cert(),
db576632
DSH
142X509_STORE_CTX_set0_crls() and X509_STORE_CTX_set0_param() do not return
143values.
144
145X509_STORE_CTX_set_default() returns 1 for success or 0 if an error occurred.
146
7f3f41d8
MC
147X509_STORE_CTX_get_num_untrusted() returns the number of untrusted certificates
148used.
149
db576632
DSH
150=head1 SEE ALSO
151
9b86974e
RS
152L<X509_verify_cert(3)>
153L<X509_VERIFY_PARAM_set_flags(3)>
db576632
DSH
154
155=head1 HISTORY
156
157X509_STORE_CTX_set0_crls() was first added to OpenSSL 1.0.0
7f3f41d8 158X509_STORE_CTX_get_num_untrusted() was first added to OpenSSL 1.1.0
db576632
DSH
159
160=cut