1 .\" $OpenBSD: SSL_CTX_load_verify_locations.3,v 1.2 2016/11/30 14:16:38 schwarze Exp $
2 .\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
4 .\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
5 .\" Copyright (c) 2000, 2001, 2015, 2016 The OpenSSL Project.
6 .\" All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in
17 .\" the documentation and/or other materials provided with the
20 .\" 3. All advertising materials mentioning features or use of this
21 .\" software must display the following acknowledgment:
22 .\" "This product includes software developed by the OpenSSL Project
23 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 .\" endorse or promote products derived from this software without
27 .\" prior written permission. For written permission, please contact
28 .\" openssl-core@openssl.org.
30 .\" 5. Products derived from this software may not be called "OpenSSL"
31 .\" nor may "OpenSSL" appear in their names without prior written
32 .\" permission of the OpenSSL Project.
34 .\" 6. Redistributions of any form whatsoever must retain the following
36 .\" "This product includes software developed by the OpenSSL Project
37 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
52 .Dd $Mdocdate: November 30 2016 $
53 .Dt SSL_CTX_LOAD_VERIFY_LOCATIONS 3
56 .Nm SSL_CTX_load_verify_locations ,
57 .Nm SSL_CTX_set_default_verify_paths
58 .Nd set default locations for trusted CA certificates
62 .Fo SSL_CTX_load_verify_locations
63 .Fa "SSL_CTX *ctx" "const char *CAfile" "const char *CApath"
66 .Fo SSL_CTX_set_default_verify_paths
70 .Fn SSL_CTX_load_verify_locations
71 specifies the locations for
73 at which CA certificates for verification purposes are located.
74 The certificates available via
80 .Fn SSL_CTX_set_default_verify_paths
81 specifies that the default locations from which CA certificates are
82 loaded should be used.
83 There is one default directory and one default file.
84 The default CA certificates directory is called
86 in the default OpenSSL directory.
87 The default CA certificates file is called
89 in the default OpenSSL directory.
95 it points to a file of CA certificates in PEM format.
96 The file can contain several CA certificates identified by sequences of:
98 -----BEGIN CERTIFICATE-----
99 ... (CA certificate in base64 encoding) ...
100 -----END CERTIFICATE-----
103 Before, between, and after the certificates arbitrary text is allowed which can
104 be used, e.g., for descriptions of the certificates.
108 is processed on execution of the
109 .Fn SSL_CTX_load_verify_locations
114 is not NULL, it points to a directory containing CA certificates in PEM format.
115 The files each contain one CA certificate.
116 The files are looked up by the CA subject name hash value,
117 which must hence be available.
118 If more than one CA certificate with the same name hash value exist,
119 the extension must be different (e.g.,
123 The search is performed in the ordering of the extension number,
124 regardless of other properties of the certificates.
128 are only looked up when required, e.g., when building the certificate chain or
129 when actually performing the verification of a peer certificate.
131 When looking up CA certificates, the OpenSSL library will first search the
136 Certificate matching is done based on the subject name, the key identifier (if
137 present), and the serial number as taken from the certificate to be verified.
138 If these data do not match, the next certificate will be tried.
139 If a first certificate matching the parameters is found,
140 the verification process will be performed;
141 no other certificates for the same parameters will be searched in case of
144 In server mode, when requesting a client certificate, the server must send
145 the list of CAs of which it will accept client certificates.
146 This list is not influenced by the contents of
150 and must explicitly be set using the
151 .Xr SSL_CTX_set_client_CA_list 3
154 When building its own certificate chain, an OpenSSL client/server will try to
155 fill in missing certificates from
156 .Fa CAfile Ns / Fa CApath ,
158 certificate chain was not explicitly specified (see
159 .Xr SSL_CTX_add_extra_chain_cert 3
161 .Xr SSL_CTX_use_certificate 3 ) .
164 .Fn SSL_CTX_load_verify_locations ,
165 the following return values can occur:
168 The operation failed because
174 or the processing at one of the locations specified failed.
175 Check the error stack to find out the reason.
177 The operation succeeded.
180 .Fn SSL_CTX_set_default_verify_paths
181 returns 1 on success or 0 on failure.
182 A missing default location is still treated as a success.
184 Generate a CA certificate file with descriptive text from the CA certificates
191 for i in ca1.pem ca2.pem ca3.pem; do
192 openssl x509 -in $i -text >> CAfile.pem
196 Prepare the directory /some/where/certs containing several CA certificates
200 $ cd /some/where/certs
201 $ rm -f *.[0-9]* *.r[0-9]*
203 > [ "$c" = "*.pem" ] && continue
204 > hash=$(openssl x509 -noout -hash -in "$c")
205 > if egrep -q -- '-BEGIN( X509 | TRUSTED | )CERTIFICATE-' "$c"; then
207 > while [ -e $hash.$suf ]; do suf=$(( $suf + 1 )); done
208 > ln -s "$c" $hash.$suf
210 > if egrep -q -- '-BEGIN X509 CRL-' "$c"; then
212 > while [ -e $hash.r$suf ]; do suf=$(( $suf + 1 )); done
213 > ln -s "$c" $hash.r$suf
219 .Xr SSL_CTX_add_extra_chain_cert 3 ,
220 .Xr SSL_CTX_set_cert_store 3 ,
221 .Xr SSL_CTX_set_client_CA_list 3 ,
222 .Xr SSL_CTX_use_certificate 3 ,
223 .Xr SSL_get_client_CA_list 3
225 If several CA certificates matching the name, key identifier, and serial
226 number condition are available, only the first one will be examined.
227 This may lead to unexpected results if the same CA certificate is available
228 with different expiration dates.
230 .Dq certificate expired
231 verification error occurs, no other certificate will be searched.
232 Make sure to not have expired certificates mixed with valid ones.