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