SSL_CTX_load_verify_locations.pod 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. =pod
  2. =head1 NAME
  3. SSL_CTX_load_verify_locations - set default locations for trusted CA
  4. certificates
  5. =head1 SYNOPSIS
  6. #include <openssl/ssl.h>
  7. int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
  8. const char *CApath);
  9. =head1 DESCRIPTION
  10. SSL_CTX_load_verify_locations() specifies the locations for B<ctx>, at
  11. which CA certificates for verification purposes are located. The certificates
  12. available via B<CAfile> and B<CApath> are trusted.
  13. =head1 NOTES
  14. If B<CAfile> is not NULL, it points to a file of CA certificates in PEM
  15. format. The file can contain several CA certificates identified by
  16. -----BEGIN CERTIFICATE-----
  17. ... (CA certificate in base64 encoding) ...
  18. -----END CERTIFICATE-----
  19. sequences. Before, between, and after the certificates text is allowed
  20. which can be used e.g. for descriptions of the certificates.
  21. The B<CAfile> is processed on execution of the SSL_CTX_load_verify_locations()
  22. function.
  23. If B<CApath> is not NULL, it points to a directory containing CA certificates
  24. in PEM format. The files each contain one CA certificate. The files are
  25. looked up by the CA subject name hash value, which must hence be available.
  26. If more than one CA certificate with the same name hash value exist, the
  27. extension must be different (e.g. 9d66eef0.0, 9d66eef0.1 etc). The search
  28. is performed in the ordering of the extension number, regardless of other
  29. properties of the certificates.
  30. Use the B<c_rehash> utility to create the necessary links.
  31. The certificates in B<CApath> are only looked up when required, e.g. when
  32. building the certificate chain or when actually performing the verification
  33. of a peer certificate.
  34. When looking up CA certificates, the OpenSSL library will first search the
  35. certificates in B<CAfile>, then those in B<CApath>. Certificate matching
  36. is done based on the subject name, the key identifier (if present), and the
  37. serial number as taken from the certificate to be verified. If these data
  38. do not match, the next certificate will be tried. If a first certificate
  39. matching the parameters is found, the verification process will be performed;
  40. no other certificates for the same parameters will be searched in case of
  41. failure.
  42. In server mode, when requesting a client certificate, the server must send
  43. the list of CAs of which it will accept client certificates. This list
  44. is not influenced by the contents of B<CAfile> or B<CApath> and must
  45. explicitly be set using the
  46. L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>
  47. family of functions.
  48. When building its own certificate chain, an OpenSSL client/server will
  49. try to fill in missing certificates from B<CAfile>/B<CApath>, if the
  50. certificate chain was not explicitly specified (see
  51. L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>,
  52. L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>.
  53. =head1 WARNINGS
  54. If several CA certificates matching the name, key identifier, and serial
  55. number condition are available, only the first one will be examined. This
  56. may lead to unexpected results if the same CA certificate is available
  57. with different expiration dates. If a "certificate expired" verification
  58. error occurs, no other certificate will be searched. Make sure to not
  59. have expired certificates mixed with valid ones.
  60. =head1 EXAMPLES
  61. Generate a CA certificate file with descriptive text from the CA certificates
  62. ca1.pem ca2.pem ca3.pem:
  63. #!/bin/sh
  64. rm CAfile.pem
  65. for i in ca1.pem ca2.pem ca3.pem ; do
  66. openssl x509 -in $i -text >> CAfile.pem
  67. done
  68. Prepare the directory /some/where/certs containing several CA certificates
  69. for use as B<CApath>:
  70. cd /some/where/certs
  71. c_rehash .
  72. =head1 RETURN VALUES
  73. The following return values can occur:
  74. =over 4
  75. =item 0
  76. The operation failed because B<CAfile> and B<CApath> are NULL or the
  77. processing at one of the locations specified failed. Check the error
  78. stack to find out the reason.
  79. =item 1
  80. The operation succeeded.
  81. =back
  82. =head1 SEE ALSO
  83. L<ssl(3)|ssl(3)>,
  84. L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>,
  85. L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>,
  86. L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,
  87. L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>,
  88. L<SSL_CTX_set_cert_store(3)|SSL_CTX_set_cert_store(3)>
  89. =cut