Documentation on using the SSL library with non-blocking I/O.
[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 =head1 DESCRIPTION
16
17 SSL_CTX_load_verify_locations() specifies the locations for B<ctx>, at
18 which CA certificates for verification purposes are located. The certificates
19 available via B<CAfile> and B<CApath> are trusted.
20
21 =head1 NOTES
22
23 If B<CAfile> is not NULL, it points to a file of CA certificates in PEM
24 format. The file can contain several CA certificates identified by
25
26  -----BEGIN CERTIFICATE-----
27  ... (CA certificate in base64 encoding) ...
28  -----END CERTIFICATE-----
29
30 sequences. Before, between, and after the certificates text is allowed
31 which can be used e.g. for descriptions of the certificates.
32
33 The B<CAfile> is processed on execution of the SSL_CTX_load_verify_locations()
34 function.
35
36 If on an TLS/SSL server no special setting is perfomed using *client_CA_list()
37 functions, the certificates contained in B<CAfile> are listed to the client
38 as available CAs during the TLS/SSL handshake.
39
40 If B<CApath> is not NULL, it points to a directory containing CA certificates
41 in PEM format. The files each contain one CA certificate. The files are
42 looked up by the CA subject name hash value, which must hence be available.
43 If more than one CA certificate with the same name hash value exist, the
44 extension must be different (e.g. 9d66eef0.0, 9d66eef0.1 etc). The search
45 is performed in the ordering of the extension number, regardless of other
46 properties of the certificates.
47 Use the B<c_rehash> utility to create the necessary links.
48
49 The certificates in B<CAfile> are only looked up when required, e.g. when
50 building the certificate chain or when actually performing the verification
51 of a peer certificate.
52
53 On a server, the certificates in B<CApath> are not listed as available
54 CA certificates to a client during a TLS/SSL handshake.
55
56 When looking up CA certificates, the OpenSSL library will first search the
57 certificates in B<CAfile>, then those in B<CApath>. Certificate matching
58 is done based on the subject name, the key identifier (if present), and the
59 serial number as taken from the certificate to be verified. If these data
60 do not match, the next certificate will be tried. If a first certificate
61 matching the parameters is found, the verification process will be performed;
62 no other certificates for the same parameters will be searched in case of
63 failure.
64
65 =head1 WARNINGS
66
67 If several CA certificates matching the name, key identifier, and serial
68 number condition are available, only the first one will be examined. This
69 may lead to unexpected results if the same CA certificate is available
70 with different expiration dates. If a "certificate expired" verification
71 error occurs, no other certificate will be searched. Make sure to not
72 have expired certificates mixed with valid ones.
73
74 =head1 EXAMPLES
75
76 Generate a CA certificate file with descriptive text from the CA certificates
77 ca1.pem ca2.pem ca3.pem:
78
79  #!/bin/sh
80  rm CAfile.pem
81  for i in ca1.pem ca2.pem ca3.pem ; do
82    openssl x509 -in $i -text >> CAfile.pem
83  done
84
85 Prepare the directory /some/where/certs containing several CA certificates
86 for use as B<CApath>:
87
88  cd /some/where/certs
89  c_rehash .
90
91 =head1 RETURN VALUES
92
93 The following return values can occur:
94
95 =over 4
96
97 =item 0
98
99 The operation failed because B<CAfile> and B<CApath> are NULL or the
100 processing at one of the locations specified failed. Check the error
101 stack to find out the reason.
102
103 =item 1
104
105 The operation succeeded.
106
107 =back
108
109 =head1 SEE ALSO
110
111 L<ssl(3)|ssl(3)>,
112 L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>,
113 L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>
114
115 =cut