A local copy of OpenSSL from GitHub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

191 lines
6.8 KiB

  1. =pod
  2. =head1 NAME
  4. X509_LOOKUP_new, X509_LOOKUP_free, X509_LOOKUP_init,
  5. X509_LOOKUP_shutdown,
  6. X509_LOOKUP_set_method_data, X509_LOOKUP_get_method_data,
  7. X509_LOOKUP_ctrl,
  8. X509_LOOKUP_load_file, X509_LOOKUP_add_dir, X509_LOOKUP_add_store,
  9. X509_LOOKUP_load_store,
  10. X509_LOOKUP_get_store, X509_LOOKUP_by_subject,
  11. X509_LOOKUP_by_issuer_serial, X509_LOOKUP_by_fingerprint,
  12. X509_LOOKUP_by_alias
  13. - OpenSSL certificate lookup mechanisms
  14. =head1 SYNOPSIS
  15. #include <openssl/x509_vfy.h>
  16. typedef x509_lookup_st X509_LOOKUP;
  17. typedef enum X509_LOOKUP_TYPE;
  18. X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);
  19. int X509_LOOKUP_init(X509_LOOKUP *ctx);
  20. int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
  21. void X509_LOOKUP_free(X509_LOOKUP *ctx);
  22. int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data);
  23. void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx);
  24. int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
  25. long argl, char **ret);
  26. int X509_LOOKUP_load_file(X509_LOOKUP *ctx, char *name, long type);
  27. int X509_LOOKUP_add_dir(X509_LOOKUP *ctx, char *name, long type);
  28. int X509_LOOKUP_add_store(X509_LOOKUP *ctx, char *uri);
  29. int X509_LOOKUP_load_store(X509_LOOKUP *ctx, char *uri);
  30. X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx);
  31. int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
  32. X509_NAME *name, X509_OBJECT *ret);
  33. int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
  34. X509_NAME *name, ASN1_INTEGER *serial,
  35. X509_OBJECT *ret);
  36. int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
  37. const unsigned char *bytes, int len,
  38. X509_OBJECT *ret);
  39. int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
  40. const char *str, int len, X509_OBJECT *ret);
  41. =head1 DESCRIPTION
  42. The B<X509_LOOKUP> structure holds the information needed to look up
  43. certificates and CRLs according to an associated L<X509_LOOKUP_METHOD(3)>.
  44. Multiple B<X509_LOOKUP> instances can be added to an L<X509_STORE(3)>
  45. to enable lookup in that store.
  46. X509_LOOKUP_new() creates a new B<X509_LOOKUP> using the given lookup
  47. I<method>.
  48. It can also be created by calling L<X509_STORE_add_lookup(3)>, which
  49. will associate a B<X509_STORE> with the lookup mechanism.
  50. X509_LOOKUP_init() initializes the internal state and resources as
  51. needed by the given B<X509_LOOKUP> to do its work.
  52. X509_LOOKUP_shutdown() tears down the internal state and resources of
  53. the given B<X509_LOOKUP>.
  54. X509_LOOKUP_free() destructs the given B<X509_LOOKUP>.
  55. X509_LOOKUP_set_method_data() and X509_LOOKUP_get_method_data()
  56. associates and retrieves a pointer to application data to and from the
  57. given B<X509_LOOKUP>, respectively.
  58. X509_LOOKUP_ctrl() is used to set or get additional data to or from a
  59. B<X509_LOOKUP> structure or its associated L<X509_LOOKUP_METHOD(3)>.
  60. The arguments of the control command are passed via I<argc> and I<argl>,
  61. its return value via I<*ret>.
  62. The meaning of the arguments depends on the I<cmd> number of the
  63. control command. In general, this function is not called directly, but
  64. wrapped by a macro call, see below.
  65. The control I<cmd>s known to OpenSSL are discussed in more depth
  66. in L</Control Commands>.
  67. X509_LOOKUP_load_file() passes a filename to be loaded immediately
  68. into the associated B<X509_STORE>.
  69. I<type> indicates what type of object is expected.
  70. This can only be used with a lookup using the implementation
  71. L<X509_LOOKUP_file(3)>.
  72. X509_LOOKUP_add_dir() passes a directory specification from which
  73. certificates and CRLs are loaded on demand into the associated
  74. B<X509_STORE>.
  75. I<type> indicates what type of object is expected.
  76. This can only be used with a lookup using the implementation
  77. L<X509_LOOKUP_hash_dir(3)>.
  78. X509_LOOKUP_add_store() passes a URI for a directory-like structure
  79. from which containers with certificates and CRLs are loaded on demand
  80. into the associated B<X509_STORE>.
  81. X509_LOOKUP_load_store() passes a URI for a single container from
  82. which certificates and CRLs are immediately loaded into the associated
  83. B<X509_STORE>.
  84. These functions can only be used with a lookup using the
  85. implementation L<X509_LOOKUP_store(3)>.
  86. X509_LOOKUP_load_file(), X509_LOOKUP_add_dir(),
  87. X509_LOOKUP_add_store(), and X509_LOOKUP_load_store() are implemented
  88. as macros that use X509_LOOKUP_ctrl().
  89. X509_LOOKUP_by_subject(), X509_LOOKUP_by_issuer_serial(),
  90. X509_LOOKUP_by_fingerprint(), and X509_LOOKUP_by_alias() look up
  91. certificates and CRLs in the L<X509_STORE(3)> associated with the
  92. B<X509_LOOKUP> using different criteria, where the looked up object is
  93. stored in I<ret>.
  94. Some of the underlying B<X509_LOOKUP_METHOD>s will also cache objects
  95. matching the criteria in the associated B<X509_STORE>, which makes it
  96. possible to handle cases where the criteria have more than one hit.
  97. =head2 Control Commands
  98. The B<X509_LOOKUP_METHOD>s built into OpenSSL recognise the following
  99. X509_LOOKUP_ctrl() I<cmd>s:
  100. =over 4
  101. =item B<X509_L_FILE_LOAD>
  102. This is the command that X509_LOOKUP_load_file() uses.
  103. The filename is passed in I<argc>, and the type in I<argl>.
  104. =item B<X509_L_ADD_DIR>
  105. This is the command that X509_LOOKUP_add_dir() uses.
  106. The directory specification is passed in I<argc>, and the type in
  107. I<argl>.
  108. =item B<X509_L_ADD_STORE>
  109. This is the command that X509_LOOKUP_add_store() uses.
  110. The URI is passed in I<argc>.
  111. =item B<X509_L_LOAD_STORE>
  112. This is the command that X509_LOOKUP_load_store() uses.
  113. The URI is passed in I<argc>.
  114. =back
  115. =head1 RETURN VALUES
  116. X509_LOOKUP_new() returns a B<X509_LOOKUP> pointer when successful,
  117. or NULL on error.
  118. X509_LOOKUP_init() and X509_LOOKUP_shutdown() return 1 on success, or
  119. 0 on error.
  120. X509_LOOKUP_ctrl() returns -1 if the B<X509_LOOKUP> doesn't have an
  121. associated B<X509_LOOKUP_METHOD>, or 1 if the X<509_LOOKUP_METHOD>
  122. doesn't have a control function.
  123. Otherwise, it returns what the control function in the
  124. B<X509_LOOKUP_METHOD> returns, which is usually 1 on success and 0 in
  125. error.
  126. X509_LOOKUP_get_store() returns a B<X509_STORE> pointer if there is
  127. one, otherwise NULL.
  128. X509_LOOKUP_by_subject(), X509_LOOKUP_by_issuer_serial(),
  129. X509_LOOKUP_by_fingerprint(), and X509_LOOKUP_by_alias() all return 0
  130. if there is no B<X509_LOOKUP_METHOD> or that method doesn't implement
  131. the corresponding function.
  132. Otherwise, it returns what the corresponding function in the
  133. B<X509_LOOKUP_METHOD> returns, which is usually 1 on success and 0 in
  134. error.
  135. =head1 SEE ALSO
  136. L<X509_LOOKUP_METHOD(3)>, L<X509_STORE(3)>
  137. =head1 COPYRIGHT
  138. Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
  139. Licensed under the Apache License 2.0 (the "License"). You may not use
  140. this file except in compliance with the License. You can obtain a copy
  141. in the file LICENSE in the source distribution or at
  142. L<https://www.openssl.org/source/license.html>.
  143. =cut