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