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