Constify X509_PUBKEY_get(), X509_PUBKEY_get0(), and X509_PUBKEY_get0_param()
[openssl.git] / doc / man3 / X509_STORE_add_cert.pod
1 =pod
2
3 =head1 NAME
4
5 X509_STORE,
6 X509_STORE_add_cert, X509_STORE_add_crl, X509_STORE_set_depth,
7 X509_STORE_set_flags, X509_STORE_set_purpose, X509_STORE_set_trust,
8 X509_STORE_add_lookup,
9 X509_STORE_load_file, X509_STORE_load_path, X509_STORE_load_store,
10 X509_STORE_set_default_paths,
11 X509_STORE_load_locations
12 - X509_STORE manipulation
13
14 =head1 SYNOPSIS
15
16  #include <openssl/x509_vfy.h>
17
18  typedef x509_store_st X509_STORE;
19
20  int X509_STORE_add_cert(X509_STORE *ctx, X509 *x);
21  int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);
22  int X509_STORE_set_depth(X509_STORE *store, int depth);
23  int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags);
24  int X509_STORE_set_purpose(X509_STORE *ctx, int purpose);
25  int X509_STORE_set_trust(X509_STORE *ctx, int trust);
26
27  X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *store,
28                                     X509_LOOKUP_METHOD *meth);
29
30  int X509_STORE_set_default_paths(X509_STORE *ctx);
31  int X509_STORE_load_file(X509_STORE *ctx, const char *file);
32  int X509_STORE_load_path(X509_STORE *ctx, const char *dir);
33  int X509_STORE_load_store(X509_STORE *ctx, const char *uri);
34
35 Deprecated:
36
37  int X509_STORE_load_locations(X509_STORE *ctx,
38                                const char *file, const char *dir);
39
40 =head1 DESCRIPTION
41
42 The B<X509_STORE> structure is intended to be a consolidated mechanism for
43 holding information about X.509 certificates and CRLs, and constructing
44 and validating chains of certificates terminating in trusted roots.
45 It admits multiple lookup mechanisms and efficient scaling performance
46 with large numbers of certificates, and a great deal of flexibility in
47 how validation and policy checks are performed.
48
49 L<X509_STORE_new(3)> creates an empty B<X509_STORE> structure, which contains
50 no information about trusted certificates or where such certificates
51 are located on disk, and is generally not usable.  Normally, trusted
52 certificates will be added to the B<X509_STORE> to prepare it for use,
53 via mechanisms such as X509_STORE_add_lookup() and X509_LOOKUP_file(), or
54 PEM_read_bio_X509_AUX() and X509_STORE_add_cert().  CRLs can also be added,
55 and many behaviors configured as desired.
56
57 Once the B<X509_STORE> is suitably configured, X509_STORE_CTX_new() is
58 used to instantiate a single-use B<X509_STORE_CTX> for each chain-building
59 and verification operation.  That process includes providing the end-entity
60 certificate to be verified and an additional set of untrusted certificates
61 that may be used in chain-building.  As such, it is expected that the
62 certificates included in the B<X509_STORE> are certificates that represent
63 trusted entities such as root certificate authorities (CAs).
64 OpenSSL represents these trusted certificates internally as B<X509> objects
65 with an associated B<X509_CERT_AUX>, as are produced by
66 PEM_read_bio_X509_AUX() and similar routines that refer to X509_AUX.
67 The public interfaces that operate on such trusted certificates still
68 operate on pointers to B<X509> objects, though.
69
70 X509_STORE_add_cert() and X509_STORE_add_crl() add the respective object
71 to the B<X509_STORE>'s local storage.  Untrusted objects should not be
72 added in this way.  The added object's reference count is incremented by one,
73 hence the caller retains ownership of the object and needs to free it when it
74 is no longer needed.
75
76 X509_STORE_set_depth(), X509_STORE_set_flags(), X509_STORE_set_purpose(),
77 X509_STORE_set_trust(), and X509_STORE_set1_param() set the default values
78 for the corresponding values used in certificate chain validation.  Their
79 behavior is documented in the corresponding B<X509_VERIFY_PARAM> manual
80 pages, e.g., L<X509_VERIFY_PARAM_set_depth(3)>.
81
82 X509_STORE_add_lookup() finds or creates a L<X509_LOOKUP(3)> with the
83 L<X509_LOOKUP_METHOD(3)> I<meth> and adds it to the B<X509_STORE>
84 I<store>.  This also associates the B<X509_STORE> with the lookup, so
85 B<X509_LOOKUP> functions can look up objects in that store.
86
87 X509_STORE_load_file() loads trusted certificate(s) into an
88 B<X509_STORE> from a given file.
89
90 X509_STORE_load_path() loads trusted certificate(s) into an
91 B<X509_STORE> from a given directory path.
92 The certificates in the directory must be in hashed form, as
93 documented in L<X509_LOOKUP_hash_dir(3)>.
94
95 X509_STORE_load_store() loads trusted certificate(s) into an
96 B<X509_STORE> from a store at a given URI.
97
98 X509_STORE_load_locations() combines X509_STORE_load_file() and
99 X509_STORE_load_dir() for a given file and/or directory path.
100 It is permitted to specify just a file, just a directory, or both
101 paths.
102
103 X509_STORE_set_default_paths() is somewhat misnamed, in that it does not
104 set what default paths should be used for loading certificates.  Instead,
105 it loads certificates into the B<X509_STORE> from the hardcoded default
106 paths.
107
108 =head1 RETURN VALUES
109
110 X509_STORE_add_cert(), X509_STORE_add_crl(), X509_STORE_set_depth(),
111 X509_STORE_set_flags(), X509_STORE_set_purpose(),
112 X509_STORE_set_trust(), X509_STORE_load_file(),
113 X509_STORE_load_path(), X509_STORE_load_store(),
114 X509_STORE_load_locations(), and X509_STORE_set_default_paths() return
115 1 on success or 0 on failure.
116
117 X509_STORE_add_lookup() returns the found or created
118 L<X509_LOOKUP(3)>, or NULL on error.
119
120 =head1 SEE ALSO
121
122 L<X509_LOOKUP_hash_dir(3)>.
123 L<X509_VERIFY_PARAM_set_depth(3)>.
124 L<X509_STORE_new(3)>,
125 L<X509_STORE_get0_param(3)>
126
127 =head1 COPYRIGHT
128
129 Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
130
131 Licensed under the Apache License 2.0 (the "License").  You may not use
132 this file except in compliance with the License.  You can obtain a copy
133 in the file LICENSE in the source distribution or at
134 L<https://www.openssl.org/source/license.html>.
135
136 =cut