1SSL_CTX_load_verify_locations(3) OpenSSL SSL_CTX_load_verify_locations(3)
2
3
4
6 SSL_CTX_load_verify_locations - set default locations for trusted CA
7 certificates
8
10 #include <openssl/ssl.h>
11
12 int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
13 const char *CApath);
14
16 SSL_CTX_load_verify_locations() specifies the locations for ctx, at
17 which CA certificates for verification purposes are located. The cer‐
18 tificates available via CAfile and CApath are trusted.
19
21 If CAfile is not NULL, it points to a file of CA certificates in PEM
22 format. The file can contain several CA certificates identified by
23
24 -----BEGIN CERTIFICATE-----
25 ... (CA certificate in base64 encoding) ...
26 -----END CERTIFICATE-----
27
28 sequences. Before, between, and after the certificates text is allowed
29 which can be used e.g. for descriptions of the certificates.
30
31 The CAfile is processed on execution of the SSL_CTX_load_verify_loca‐
32 tions() function.
33
34 If CApath is not NULL, it points to a directory containing CA certifi‐
35 cates in PEM format. The files each contain one CA certificate. The
36 files are looked up by the CA subject name hash value, which must hence
37 be available. If more than one CA certificate with the same name hash
38 value exist, the extension must be different (e.g. 9d66eef0.0,
39 9d66eef0.1 etc). The search is performed in the ordering of the exten‐
40 sion number, regardless of other properties of the certificates. Use
41 the c_rehash utility to create the necessary links.
42
43 The certificates in CApath are only looked up when required, e.g. when
44 building the certificate chain or when actually performing the verifi‐
45 cation of a peer certificate.
46
47 When looking up CA certificates, the OpenSSL library will first search
48 the certificates in CAfile, then those in CApath. Certificate matching
49 is done based on the subject name, the key identifier (if present), and
50 the serial number as taken from the certificate to be verified. If
51 these data do not match, the next certificate will be tried. If a first
52 certificate matching the parameters is found, the verification process
53 will be performed; no other certificates for the same parameters will
54 be searched in case of failure.
55
56 In server mode, when requesting a client certificate, the server must
57 send the list of CAs of which it will accept client certificates. This
58 list is not influenced by the contents of CAfile or CApath and must
59 explicitly be set using the SSL_CTX_set_client_CA_list(3) family of
60 functions.
61
62 When building its own certificate chain, an OpenSSL client/server will
63 try to fill in missing certificates from CAfile/CApath, if the certifi‐
64 cate chain was not explicitly specified (see
65 SSL_CTX_add_extra_chain_cert(3), SSL_CTX_use_certificate(3).
66
68 If several CA certificates matching the name, key identifier, and
69 serial number condition are available, only the first one will be exam‐
70 ined. This may lead to unexpected results if the same CA certificate is
71 available with different expiration dates. If a "certificate expired"
72 verification error occurs, no other certificate will be searched. Make
73 sure to not have expired certificates mixed with valid ones.
74
76 Generate a CA certificate file with descriptive text from the CA cer‐
77 tificates 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 certifi‐
86 cates for use as CApath:
87
88 cd /some/where/certs
89 c_rehash .
90
92 The following return values can occur:
93
94 0 The operation failed because CAfile and CApath are NULL or the pro‐
95 cessing at one of the locations specified failed. Check the error
96 stack to find out the reason.
97
98 1 The operation succeeded.
99
101 ssl(3), SSL_CTX_set_client_CA_list(3), SSL_get_client_CA_list(3),
102 SSL_CTX_use_certificate(3), SSL_CTX_add_extra_chain_cert(3),
103 SSL_CTX_set_cert_store(3)
104
105
106
1070.9.8b 2001-09-07 SSL_CTX_load_verify_locations(3)