2
0

X509_STORE_add_cert.pod 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. =pod
  2. =head1 NAME
  3. X509_STORE,
  4. X509_STORE_add_cert, X509_STORE_add_crl, X509_STORE_set_depth,
  5. X509_STORE_set_flags, X509_STORE_set_purpose, X509_STORE_set_trust,
  6. X509_STORE_add_lookup,
  7. X509_STORE_load_file_ex, X509_STORE_load_file, X509_STORE_load_path,
  8. X509_STORE_load_store_ex, X509_STORE_load_store,
  9. X509_STORE_set_default_paths_ex, X509_STORE_set_default_paths,
  10. X509_STORE_load_locations_ex, X509_STORE_load_locations
  11. - X509_STORE manipulation
  12. =head1 SYNOPSIS
  13. #include <openssl/x509_vfy.h>
  14. typedef x509_store_st X509_STORE;
  15. int X509_STORE_add_cert(X509_STORE *xs, X509 *x);
  16. int X509_STORE_add_crl(X509_STORE *xs, X509_CRL *x);
  17. int X509_STORE_set_depth(X509_STORE *store, int depth);
  18. int X509_STORE_set_flags(X509_STORE *xs, unsigned long flags);
  19. int X509_STORE_set_purpose(X509_STORE *xs, int purpose);
  20. int X509_STORE_set_trust(X509_STORE *xs, int trust);
  21. X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *store,
  22. X509_LOOKUP_METHOD *meth);
  23. int X509_STORE_set_default_paths_ex(X509_STORE *xs, OSSL_LIB_CTX *libctx,
  24. const char *propq);
  25. int X509_STORE_set_default_paths(X509_STORE *xs);
  26. int X509_STORE_load_file_ex(X509_STORE *xs, const char *file,
  27. OSSL_LIB_CTX *libctx, const char *propq);
  28. int X509_STORE_load_file(X509_STORE *xs, const char *file);
  29. int X509_STORE_load_path(X509_STORE *xs, const char *dir);
  30. int X509_STORE_load_store_ex(X509_STORE *xs, const char *uri,
  31. OSSL_LIB_CTX *libctx, const char *propq);
  32. int X509_STORE_load_store(X509_STORE *xs, const char *uri);
  33. int X509_STORE_load_locations_ex(X509_STORE *xs, const char *file,
  34. const char *dir, OSSL_LIB_CTX *libctx,
  35. const char *propq);
  36. int X509_STORE_load_locations(X509_STORE *xs,
  37. const char *file, const char *dir);
  38. =head1 DESCRIPTION
  39. The B<X509_STORE> structure is intended to be a consolidated mechanism for
  40. holding information about X.509 certificates and CRLs, and constructing
  41. and validating chains of certificates terminating in trusted roots.
  42. It admits multiple lookup mechanisms and efficient scaling performance
  43. with large numbers of certificates, and a great deal of flexibility in
  44. how validation and policy checks are performed.
  45. Details of the chain building and checking process are described in
  46. L<openssl-verification-options(1)/Certification Path Building> and
  47. L<openssl-verification-options(1)/Certification Path Validation>.
  48. L<X509_STORE_new(3)> creates an empty B<X509_STORE> structure, which contains
  49. no information about trusted certificates or where such certificates
  50. are located on disk, and is generally not usable. Normally, trusted
  51. certificates will be added to the B<X509_STORE> to prepare it for use,
  52. via mechanisms such as X509_STORE_add_lookup() and X509_LOOKUP_file(), or
  53. PEM_read_bio_X509_AUX() and X509_STORE_add_cert(). CRLs can also be added,
  54. and many behaviors configured as desired.
  55. Once the B<X509_STORE> is suitably configured, X509_STORE_CTX_new() is
  56. used to instantiate a single-use B<X509_STORE_CTX> for each chain-building
  57. and verification operation. That process includes providing the end-entity
  58. certificate to be verified and an additional set of untrusted certificates
  59. that may be used in chain-building. As such, it is expected that the
  60. certificates included in the B<X509_STORE> are certificates that represent
  61. trusted entities such as root certificate authorities (CAs).
  62. OpenSSL represents these trusted certificates internally as B<X509> objects
  63. with an associated B<X509_CERT_AUX>, as are produced by
  64. PEM_read_bio_X509_AUX() and similar routines that refer to X509_AUX.
  65. The public interfaces that operate on such trusted certificates still
  66. operate on pointers to B<X509> objects, though.
  67. X509_STORE_add_cert() and X509_STORE_add_crl() add the respective object
  68. to the B<X509_STORE>'s local storage. Untrusted objects should not be
  69. added in this way. The added object's reference count is incremented by one,
  70. hence the caller retains ownership of the object and needs to free it when it
  71. is no longer needed.
  72. X509_STORE_set_depth(), X509_STORE_set_flags(), X509_STORE_set_purpose(),
  73. X509_STORE_set_trust(), and X509_STORE_set1_param() set the default values
  74. for the corresponding values used in certificate chain validation. Their
  75. behavior is documented in the corresponding B<X509_VERIFY_PARAM> manual
  76. pages, e.g., L<X509_VERIFY_PARAM_set_depth(3)>.
  77. X509_STORE_add_lookup() finds or creates a L<X509_LOOKUP(3)> with the
  78. L<X509_LOOKUP_METHOD(3)> I<meth> and adds it to the B<X509_STORE>
  79. I<store>. This also associates the B<X509_STORE> with the lookup, so
  80. B<X509_LOOKUP> functions can look up objects in that store.
  81. X509_STORE_load_file_ex() loads trusted certificate(s) into an
  82. B<X509_STORE> from a given file. The library context I<libctx> and property
  83. query I<propq> are used when fetching algorithms from providers.
  84. X509_STORE_load_file() is similar to X509_STORE_load_file_ex() but
  85. uses NULL for the library context I<libctx> and property query I<propq>.
  86. X509_STORE_load_path() loads trusted certificate(s) into an
  87. B<X509_STORE> from a given directory path.
  88. The certificates in the directory must be in hashed form, as
  89. documented in L<X509_LOOKUP_hash_dir(3)>.
  90. X509_STORE_load_store_ex() loads trusted certificate(s) into an
  91. B<X509_STORE> from a store at a given URI. The library context I<libctx> and
  92. property query I<propq> are used when fetching algorithms from providers.
  93. X509_STORE_load_store() is similar to X509_STORE_load_store_ex() but
  94. uses NULL for the library context I<libctx> and property query I<propq>.
  95. X509_STORE_load_locations_ex() combines
  96. X509_STORE_load_file_ex() and X509_STORE_load_path() for a given file
  97. and/or directory path.
  98. It is permitted to specify just a file, just a directory, or both
  99. paths.
  100. X509_STORE_load_locations() is similar to X509_STORE_load_locations_ex()
  101. but uses NULL for the library context I<libctx> and property query I<propq>.
  102. X509_STORE_set_default_paths_ex() is somewhat misnamed, in that it does
  103. not set what default paths should be used for loading certificates. Instead,
  104. it loads certificates into the B<X509_STORE> from the hardcoded default
  105. paths. The library context I<libctx> and property query I<propq> are used when
  106. fetching algorithms from providers.
  107. X509_STORE_set_default_paths() is similar to
  108. X509_STORE_set_default_paths_ex() but uses NULL for the library
  109. context I<libctx> and property query I<propq>.
  110. =head1 RETURN VALUES
  111. X509_STORE_add_cert(), X509_STORE_add_crl(), X509_STORE_set_depth(),
  112. X509_STORE_set_flags(), X509_STORE_set_purpose(), X509_STORE_set_trust(),
  113. X509_STORE_load_file_ex(), X509_STORE_load_file(),
  114. X509_STORE_load_path(),
  115. X509_STORE_load_store_ex(), X509_STORE_load_store(),
  116. X509_STORE_load_locations_ex(), X509_STORE_load_locations(),
  117. X509_STORE_set_default_paths_ex() and X509_STORE_set_default_paths()
  118. return 1 on success or 0 on failure.
  119. X509_STORE_add_lookup() returns the found or created
  120. L<X509_LOOKUP(3)>, or NULL on error.
  121. =head1 SEE ALSO
  122. L<X509_LOOKUP_hash_dir(3)>.
  123. L<X509_VERIFY_PARAM_set_depth(3)>.
  124. L<X509_STORE_new(3)>,
  125. L<X509_STORE_get0_param(3)>
  126. =head1 HISTORY
  127. The functions X509_STORE_set_default_paths_ex(),
  128. X509_STORE_load_file_ex(), X509_STORE_load_store_ex() and
  129. X509_STORE_load_locations_ex() were added in OpenSSL 3.0.
  130. =head1 COPYRIGHT
  131. Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
  132. Licensed under the Apache License 2.0 (the "License"). You may not use
  133. this file except in compliance with the License. You can obtain a copy
  134. in the file LICENSE in the source distribution or at
  135. L<https://www.openssl.org/source/license.html>.
  136. =cut