]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/SSL_CTX_load_verify_locations.pod
Implement EVP_MAC_do_all_ex()
[thirdparty/openssl.git] / doc / man3 / SSL_CTX_load_verify_locations.pod
CommitLineData
356c06c7
RL
1=pod
2
3=head1 NAME
4
c7e6ae6a
RL
5SSL_CTX_load_verify_locations, SSL_CTX_set_default_verify_paths,
6SSL_CTX_set_default_verify_dir, SSL_CTX_set_default_verify_file - set
7default locations for trusted CA certificates
356c06c7
RL
8
9=head1 SYNOPSIS
10
11 #include <openssl/ssl.h>
12
13 int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
14 const char *CApath);
15
631fb6af
MC
16 int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);
17
18 int SSL_CTX_set_default_verify_dir(SSL_CTX *ctx);
19
20 int SSL_CTX_set_default_verify_file(SSL_CTX *ctx);
21
356c06c7
RL
22=head1 DESCRIPTION
23
24SSL_CTX_load_verify_locations() specifies the locations for B<ctx>, at
25which CA certificates for verification purposes are located. The certificates
26available via B<CAfile> and B<CApath> are trusted.
27
f5de06aa 28SSL_CTX_set_default_verify_paths() specifies that the default locations from
631fb6af 29which CA certificates are loaded should be used. There is one default directory
f5de06aa
MC
30and one default file. The default CA certificates directory is called "certs" in
31the default OpenSSL directory. Alternatively the SSL_CERT_DIR environment
32variable can be defined to override this location. The default CA certificates
33file is called "cert.pem" in the default OpenSSL directory. Alternatively the
34SSL_CERT_FILE environment variable can be defined to override this location.
631fb6af
MC
35
36SSL_CTX_set_default_verify_dir() is similar to
37SSL_CTX_set_default_verify_paths() except that just the default directory is
38used.
39
40SSL_CTX_set_default_verify_file() is similar to
41SSL_CTX_set_default_verify_paths() except that just the default file is
42used.
43
356c06c7
RL
44=head1 NOTES
45
46If B<CAfile> is not NULL, it points to a file of CA certificates in PEM
47format. The file can contain several CA certificates identified by
48
49 -----BEGIN CERTIFICATE-----
50 ... (CA certificate in base64 encoding) ...
51 -----END CERTIFICATE-----
52
53sequences. Before, between, and after the certificates text is allowed
54which can be used e.g. for descriptions of the certificates.
55
56The B<CAfile> is processed on execution of the SSL_CTX_load_verify_locations()
57function.
58
356c06c7
RL
59If B<CApath> is not NULL, it points to a directory containing CA certificates
60in PEM format. The files each contain one CA certificate. The files are
61looked up by the CA subject name hash value, which must hence be available.
553615f5
RL
62If more than one CA certificate with the same name hash value exist, the
63extension must be different (e.g. 9d66eef0.0, 9d66eef0.1 etc). The search
64is performed in the ordering of the extension number, regardless of other
65properties of the certificates.
356c06c7
RL
66Use the B<c_rehash> utility to create the necessary links.
67
d766a23d 68The certificates in B<CApath> are only looked up when required, e.g. when
356c06c7
RL
69building the certificate chain or when actually performing the verification
70of a peer certificate.
71
553615f5
RL
72When looking up CA certificates, the OpenSSL library will first search the
73certificates in B<CAfile>, then those in B<CApath>. Certificate matching
74is done based on the subject name, the key identifier (if present), and the
75serial number as taken from the certificate to be verified. If these data
76do not match, the next certificate will be tried. If a first certificate
77matching the parameters is found, the verification process will be performed;
78no other certificates for the same parameters will be searched in case of
79failure.
80
638b0d42
LJ
81In server mode, when requesting a client certificate, the server must send
82the list of CAs of which it will accept client certificates. This list
83is not influenced by the contents of B<CAfile> or B<CApath> and must
3b80e3aa 84explicitly be set using the
9b86974e 85L<SSL_CTX_set_client_CA_list(3)>
638b0d42
LJ
86family of functions.
87
d766a23d 88When building its own certificate chain, an OpenSSL client/server will
66ebbb6a 89try to fill in missing certificates from B<CAfile>/B<CApath>, if the
52d160d8 90certificate chain was not explicitly specified (see
9b86974e
RS
91L<SSL_CTX_add_extra_chain_cert(3)>,
92L<SSL_CTX_use_certificate(3)>.
d766a23d 93
553615f5
RL
94=head1 WARNINGS
95
96If several CA certificates matching the name, key identifier, and serial
97number condition are available, only the first one will be examined. This
98may lead to unexpected results if the same CA certificate is available
99with different expiration dates. If a "certificate expired" verification
100error occurs, no other certificate will be searched. Make sure to not
101have expired certificates mixed with valid ones.
102
356c06c7
RL
103=head1 RETURN VALUES
104
631fb6af 105For SSL_CTX_load_verify_locations the following return values can occur:
356c06c7
RL
106
107=over 4
108
c8919dde 109=item Z<>0
356c06c7
RL
110
111The operation failed because B<CAfile> and B<CApath> are NULL or the
112processing at one of the locations specified failed. Check the error
113stack to find out the reason.
114
c8919dde 115=item Z<>1
356c06c7
RL
116
117The operation succeeded.
118
119=back
120
631fb6af
MC
121SSL_CTX_set_default_verify_paths(), SSL_CTX_set_default_verify_dir() and
122SSL_CTX_set_default_verify_file() all return 1 on success or 0 on failure. A
123missing default location is still treated as a success.
124
4564e77a
PY
125=head1 EXAMPLES
126
127Generate a CA certificate file with descriptive text from the CA certificates
128ca1.pem ca2.pem ca3.pem:
129
130 #!/bin/sh
131 rm CAfile.pem
132 for i in ca1.pem ca2.pem ca3.pem ; do
133 openssl x509 -in $i -text >> CAfile.pem
134 done
135
136Prepare the directory /some/where/certs containing several CA certificates
137for use as B<CApath>:
138
139 cd /some/where/certs
140 c_rehash .
141
356c06c7
RL
142=head1 SEE ALSO
143
b97fdb57 144L<ssl(7)>,
9b86974e
RS
145L<SSL_CTX_set_client_CA_list(3)>,
146L<SSL_get_client_CA_list(3)>,
147L<SSL_CTX_use_certificate(3)>,
148L<SSL_CTX_add_extra_chain_cert(3)>,
e0b5108c
JW
149L<SSL_CTX_set_cert_store(3)>,
150L<SSL_CTX_set_client_CA_list(3)>
356c06c7 151
e2f92610
RS
152=head1 COPYRIGHT
153
154Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
155
4746f25a 156Licensed under the Apache License 2.0 (the "License"). You may not use
e2f92610
RS
157this file except in compliance with the License. You can obtain a copy
158in the file LICENSE in the source distribution or at
159L<https://www.openssl.org/source/license.html>.
160
161=cut