X509_LOOKUP_meth_new.pod 9.0 KB

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