X509_STORE_add_cert.pod 5.5 KB

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