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