X509_LOOKUP_meth_new.pod 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. =pod
  2. =head1 NAME
  3. X509_LOOKUP_METHOD,
  4. X509_LOOKUP_meth_new, X509_LOOKUP_meth_free, X509_LOOKUP_meth_set_new_item,
  5. X509_LOOKUP_meth_get_new_item, X509_LOOKUP_meth_set_free,
  6. X509_LOOKUP_meth_get_free, X509_LOOKUP_meth_set_init,
  7. X509_LOOKUP_meth_get_init, X509_LOOKUP_meth_set_shutdown,
  8. X509_LOOKUP_meth_get_shutdown,
  9. X509_LOOKUP_ctrl_fn, X509_LOOKUP_meth_set_ctrl, X509_LOOKUP_meth_get_ctrl,
  10. X509_LOOKUP_get_by_subject_fn, X509_LOOKUP_meth_set_get_by_subject,
  11. X509_LOOKUP_meth_get_get_by_subject,
  12. X509_LOOKUP_get_by_issuer_serial_fn, X509_LOOKUP_meth_set_get_by_issuer_serial,
  13. X509_LOOKUP_meth_get_get_by_issuer_serial,
  14. X509_LOOKUP_get_by_fingerprint_fn, X509_LOOKUP_meth_set_get_by_fingerprint,
  15. X509_LOOKUP_meth_get_get_by_fingerprint,
  16. X509_LOOKUP_get_by_alias_fn, X509_LOOKUP_meth_set_get_by_alias,
  17. X509_LOOKUP_meth_get_get_by_alias,
  18. X509_OBJECT_set1_X509, X509_OBJECT_set1_X509_CRL
  19. - Routines to build up X509_LOOKUP methods
  20. =head1 SYNOPSIS
  21. #include <openssl/x509_vfy.h>
  22. typedef x509_lookup_method_st X509_LOOKUP_METHOD;
  23. X509_LOOKUP_METHOD *X509_LOOKUP_meth_new(const char *name);
  24. void X509_LOOKUP_meth_free(X509_LOOKUP_METHOD *method);
  25. int X509_LOOKUP_meth_set_new_item(X509_LOOKUP_METHOD *method,
  26. int (*new_item) (X509_LOOKUP *ctx));
  27. int (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD* method))
  28. (X509_LOOKUP *ctx);
  29. int X509_LOOKUP_meth_set_free(X509_LOOKUP_METHOD *method,
  30. void (*free) (X509_LOOKUP *ctx));
  31. void (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD* method))
  32. (X509_LOOKUP *ctx);
  33. int X509_LOOKUP_meth_set_init(X509_LOOKUP_METHOD *method,
  34. int (*init) (X509_LOOKUP *ctx));
  35. int (*X509_LOOKUP_meth_get_init(const X509_LOOKUP_METHOD* method))
  36. (X509_LOOKUP *ctx);
  37. int X509_LOOKUP_meth_set_shutdown(X509_LOOKUP_METHOD *method,
  38. int (*shutdown) (X509_LOOKUP *ctx));
  39. int (*X509_LOOKUP_meth_get_shutdown(const X509_LOOKUP_METHOD* method))
  40. (X509_LOOKUP *ctx);
  41. typedef int (*X509_LOOKUP_ctrl_fn)(X509_LOOKUP *ctx, int cmd, const char *argc,
  42. long argl, char **ret);
  43. int X509_LOOKUP_meth_set_ctrl(X509_LOOKUP_METHOD *method,
  44. X509_LOOKUP_ctrl_fn ctrl_fn);
  45. X509_LOOKUP_ctrl_fn X509_LOOKUP_meth_get_ctrl(const X509_LOOKUP_METHOD *method);
  46. typedef int (*X509_LOOKUP_get_by_subject_fn)(X509_LOOKUP *ctx,
  47. X509_LOOKUP_TYPE type,
  48. const X509_NAME *name,
  49. X509_OBJECT *ret);
  50. int X509_LOOKUP_meth_set_get_by_subject(X509_LOOKUP_METHOD *method,
  51. X509_LOOKUP_get_by_subject_fn fn);
  52. X509_LOOKUP_get_by_subject_fn X509_LOOKUP_meth_get_get_by_subject(
  53. const X509_LOOKUP_METHOD *method);
  54. typedef int (*X509_LOOKUP_get_by_issuer_serial_fn)(X509_LOOKUP *ctx,
  55. X509_LOOKUP_TYPE type,
  56. const X509_NAME *name,
  57. const ASN1_INTEGER *serial,
  58. X509_OBJECT *ret);
  59. int X509_LOOKUP_meth_set_get_by_issuer_serial(
  60. X509_LOOKUP_METHOD *method, X509_LOOKUP_get_by_issuer_serial_fn fn);
  61. X509_LOOKUP_get_by_issuer_serial_fn X509_LOOKUP_meth_get_get_by_issuer_serial(
  62. const X509_LOOKUP_METHOD *method);
  63. typedef int (*X509_LOOKUP_get_by_fingerprint_fn)(X509_LOOKUP *ctx,
  64. X509_LOOKUP_TYPE type,
  65. const unsigned char* bytes,
  66. int len,
  67. X509_OBJECT *ret);
  68. int X509_LOOKUP_meth_set_get_by_fingerprint(X509_LOOKUP_METHOD *method,
  69. X509_LOOKUP_get_by_fingerprint_fn fn);
  70. X509_LOOKUP_get_by_fingerprint_fn X509_LOOKUP_meth_get_get_by_fingerprint(
  71. const X509_LOOKUP_METHOD *method);
  72. typedef int (*X509_LOOKUP_get_by_alias_fn)(X509_LOOKUP *ctx,
  73. X509_LOOKUP_TYPE type,
  74. const char *str,
  75. int len,
  76. X509_OBJECT *ret);
  77. int X509_LOOKUP_meth_set_get_by_alias(X509_LOOKUP_METHOD *method,
  78. X509_LOOKUP_get_by_alias_fn fn);
  79. X509_LOOKUP_get_by_alias_fn X509_LOOKUP_meth_get_get_by_alias(
  80. const X509_LOOKUP_METHOD *method);
  81. int X509_OBJECT_set1_X509(X509_OBJECT *a, X509 *obj);
  82. int X509_OBJECT_set1_X509_CRL(X509_OBJECT *a, X509_CRL *obj);
  83. =head1 DESCRIPTION
  84. The B<X509_LOOKUP_METHOD> type is a structure used for the implementation of new
  85. X509_LOOKUP types. It provides a set of functions used by OpenSSL for the
  86. implementation of various X509 and X509_CRL lookup capabilities. One instance
  87. of an X509_LOOKUP_METHOD can be associated to many instantiations of an
  88. B<X509_LOOKUP> structure.
  89. X509_LOOKUP_meth_new() creates a new B<X509_LOOKUP_METHOD> structure. It should
  90. be given a human-readable string containing a brief description of the lookup
  91. method.
  92. X509_LOOKUP_meth_free() destroys a B<X509_LOOKUP_METHOD> structure.
  93. If the argument is NULL, nothing is done.
  94. X509_LOOKUP_get_new_item() and X509_LOOKUP_set_new_item() get and set the
  95. function that is called when an B<X509_LOOKUP> object is created with
  96. X509_LOOKUP_new(). If an X509_LOOKUP_METHOD requires any per-X509_LOOKUP
  97. specific data, the supplied new_item function should allocate this data and
  98. invoke L<X509_LOOKUP_set_method_data(3)>.
  99. X509_LOOKUP_get_free() and X509_LOOKUP_set_free() get and set the function
  100. that is used to free any method data that was allocated and set from within
  101. new_item function.
  102. X509_LOOKUP_meth_get_init() and X509_LOOKUP_meth_set_init() get and set the
  103. function that is used to initialize the method data that was set with
  104. L<X509_LOOKUP_set_method_data(3)> as part of the new_item routine.
  105. X509_LOOKUP_meth_get_shutdown() and X509_LOOKUP_meth_set_shutdown() get and set
  106. the function that is used to shut down the method data whose state was
  107. previously initialized in the init function.
  108. X509_LOOKUP_meth_get_ctrl() and X509_LOOKUP_meth_set_ctrl() get and set a
  109. function to be used to handle arbitrary control commands issued by
  110. X509_LOOKUP_ctrl(). The control function is given the X509_LOOKUP
  111. B<ctx>, along with the arguments passed by X509_LOOKUP_ctrl. B<cmd> is
  112. an arbitrary integer that defines some operation. B<argc> is a pointer
  113. to an array of characters. B<argl> is an integer. B<ret>, if set,
  114. points to a location where any return data should be written to. How
  115. B<argc> and B<argl> are used depends entirely on the control function.
  116. X509_LOOKUP_set_get_by_subject(), X509_LOOKUP_set_get_by_issuer_serial(),
  117. X509_LOOKUP_set_get_by_fingerprint(), X509_LOOKUP_set_get_by_alias() set
  118. the functions used to retrieve an X509 or X509_CRL object by the object's
  119. subject, issuer, fingerprint, and alias respectively. These functions are given
  120. the X509_LOOKUP context, the type of the X509_OBJECT being requested, parameters
  121. related to the lookup, and an X509_OBJECT that will receive the requested
  122. object.
  123. Implementations must add objects they find to the B<X509_STORE> object
  124. using X509_STORE_add_cert() or X509_STORE_add_crl(). This increments
  125. its reference count. However, the L<X509_STORE_CTX_get_by_subject(3)>
  126. function also increases the reference count which leads to one too
  127. many references being held. Therefore, applications should
  128. additionally call X509_free() or X509_CRL_free() to decrement the
  129. reference count again.
  130. Implementations should also use either X509_OBJECT_set1_X509() or
  131. X509_OBJECT_set1_X509_CRL() to set the result. Note that this also
  132. increments the result's reference count.
  133. Any method data that was created as a result of the new_item function
  134. set by X509_LOOKUP_meth_set_new_item() can be accessed with
  135. L<X509_LOOKUP_get_method_data(3)>. The B<X509_STORE> object that owns the
  136. X509_LOOKUP may be accessed with L<X509_LOOKUP_get_store(3)>. Successful
  137. lookups should return 1, and unsuccessful lookups should return 0.
  138. X509_LOOKUP_get_get_by_subject(), X509_LOOKUP_get_get_by_issuer_serial(),
  139. X509_LOOKUP_get_get_by_fingerprint(), X509_LOOKUP_get_get_by_alias() retrieve
  140. the function set by the corresponding setter.
  141. =head1 RETURN VALUES
  142. The B<X509_LOOKUP_meth_set> functions return 1 on success or 0 on error.
  143. The B<X509_LOOKUP_meth_get> functions return the corresponding function
  144. pointers.
  145. =head1 SEE ALSO
  146. L<X509_STORE_CTX_get_by_subject(3)>,
  147. L<X509_STORE_new(3)>, L<SSL_CTX_set_cert_store(3)>
  148. =head1 HISTORY
  149. The functions described here were added in OpenSSL 1.1.0i.
  150. =head1 COPYRIGHT
  151. Copyright 2018-2024 The OpenSSL Project Authors. All Rights Reserved.
  152. Licensed under the Apache License 2.0 (the "License"). You may not use
  153. this file except in compliance with the License. You can obtain a copy
  154. in the file LICENSE in the source distribution or at
  155. L<https://www.openssl.org/source/license.html>.
  156. =cut