5 SSL_CTX_load_verify_locations - set default locations for trusted CA
10 #include <openssl/ssl.h>
12 int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
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.
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
26 -----BEGIN CERTIFICATE-----
27 ... (CA certificate in base64 encoding) ...
28 -----END CERTIFICATE-----
30 sequences. Before, between, and after the certificates text is allowed
31 which can be used e.g. for descriptions of the certificates.
33 The B<CAfile> is processed on execution of the SSL_CTX_load_verify_locations()
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.
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 Use the B<c_rehash> utility to create the necessary links.
45 The certificates in B<CAfile> are only looked up when required, e.g. when
46 building the certificate chain or when actually performing the verification
47 of a peer certificate.
49 On a server, the certificates in B<CApath> are not listed as available
50 CA certificates to a client during a TLS/SSL handshake.
54 Generate a CA certificate file with descriptive text from the CA certificates
55 ca1.pem ca2.pem ca3.pem:
59 for i in ca1.pem ca2.pem ca3.pem ; do
60 openssl x509 -in $i -text >> CAfile.pem
63 Prepare the directory /some/where/certs containing several CA certificates
71 The following return values can occur:
77 The operation failed because B<CAfile> and B<CApath> are NULL or the
78 processing at one of the locations specified failed. Check the error
79 stack to find out the reason.
83 The operation succeeded.
90 L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>,
91 L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>