X509_LOOKUP_meth_new.3ossl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "X509_LOOKUP_METH_NEW 3ossl"
  58. .TH X509_LOOKUP_METH_NEW 3ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. X509_LOOKUP_METHOD,
  65. X509_LOOKUP_meth_new, X509_LOOKUP_meth_free, X509_LOOKUP_meth_set_new_item,
  66. X509_LOOKUP_meth_get_new_item, X509_LOOKUP_meth_set_free,
  67. X509_LOOKUP_meth_get_free, X509_LOOKUP_meth_set_init,
  68. X509_LOOKUP_meth_get_init, X509_LOOKUP_meth_set_shutdown,
  69. X509_LOOKUP_meth_get_shutdown,
  70. X509_LOOKUP_ctrl_fn, X509_LOOKUP_meth_set_ctrl, X509_LOOKUP_meth_get_ctrl,
  71. X509_LOOKUP_get_by_subject_fn, X509_LOOKUP_meth_set_get_by_subject,
  72. X509_LOOKUP_meth_get_get_by_subject,
  73. X509_LOOKUP_get_by_issuer_serial_fn, X509_LOOKUP_meth_set_get_by_issuer_serial,
  74. X509_LOOKUP_meth_get_get_by_issuer_serial,
  75. X509_LOOKUP_get_by_fingerprint_fn, X509_LOOKUP_meth_set_get_by_fingerprint,
  76. X509_LOOKUP_meth_get_get_by_fingerprint,
  77. X509_LOOKUP_get_by_alias_fn, X509_LOOKUP_meth_set_get_by_alias,
  78. X509_LOOKUP_meth_get_get_by_alias,
  79. X509_OBJECT_set1_X509, X509_OBJECT_set1_X509_CRL
  80. \&\- Routines to build up X509_LOOKUP methods
  81. .SH SYNOPSIS
  82. .IX Header "SYNOPSIS"
  83. .Vb 1
  84. \& #include <openssl/x509_vfy.h>
  85. \&
  86. \& typedef x509_lookup_method_st X509_LOOKUP_METHOD;
  87. \&
  88. \& X509_LOOKUP_METHOD *X509_LOOKUP_meth_new(const char *name);
  89. \& void X509_LOOKUP_meth_free(X509_LOOKUP_METHOD *method);
  90. \&
  91. \& int X509_LOOKUP_meth_set_new_item(X509_LOOKUP_METHOD *method,
  92. \& int (*new_item) (X509_LOOKUP *ctx));
  93. \& int (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD* method))
  94. \& (X509_LOOKUP *ctx);
  95. \&
  96. \& int X509_LOOKUP_meth_set_free(X509_LOOKUP_METHOD *method,
  97. \& void (*free) (X509_LOOKUP *ctx));
  98. \& void (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD* method))
  99. \& (X509_LOOKUP *ctx);
  100. \&
  101. \& int X509_LOOKUP_meth_set_init(X509_LOOKUP_METHOD *method,
  102. \& int (*init) (X509_LOOKUP *ctx));
  103. \& int (*X509_LOOKUP_meth_get_init(const X509_LOOKUP_METHOD* method))
  104. \& (X509_LOOKUP *ctx);
  105. \&
  106. \& int X509_LOOKUP_meth_set_shutdown(X509_LOOKUP_METHOD *method,
  107. \& int (*shutdown) (X509_LOOKUP *ctx));
  108. \& int (*X509_LOOKUP_meth_get_shutdown(const X509_LOOKUP_METHOD* method))
  109. \& (X509_LOOKUP *ctx);
  110. \&
  111. \& typedef int (*X509_LOOKUP_ctrl_fn)(X509_LOOKUP *ctx, int cmd, const char *argc,
  112. \& long argl, char **ret);
  113. \& int X509_LOOKUP_meth_set_ctrl(X509_LOOKUP_METHOD *method,
  114. \& X509_LOOKUP_ctrl_fn ctrl_fn);
  115. \& X509_LOOKUP_ctrl_fn X509_LOOKUP_meth_get_ctrl(const X509_LOOKUP_METHOD *method);
  116. \&
  117. \& typedef int (*X509_LOOKUP_get_by_subject_fn)(X509_LOOKUP *ctx,
  118. \& X509_LOOKUP_TYPE type,
  119. \& const X509_NAME *name,
  120. \& X509_OBJECT *ret);
  121. \& int X509_LOOKUP_meth_set_get_by_subject(X509_LOOKUP_METHOD *method,
  122. \& X509_LOOKUP_get_by_subject_fn fn);
  123. \& X509_LOOKUP_get_by_subject_fn X509_LOOKUP_meth_get_get_by_subject(
  124. \& const X509_LOOKUP_METHOD *method);
  125. \&
  126. \& typedef int (*X509_LOOKUP_get_by_issuer_serial_fn)(X509_LOOKUP *ctx,
  127. \& X509_LOOKUP_TYPE type,
  128. \& const X509_NAME *name,
  129. \& const ASN1_INTEGER *serial,
  130. \& X509_OBJECT *ret);
  131. \& int X509_LOOKUP_meth_set_get_by_issuer_serial(
  132. \& X509_LOOKUP_METHOD *method, X509_LOOKUP_get_by_issuer_serial_fn fn);
  133. \& X509_LOOKUP_get_by_issuer_serial_fn X509_LOOKUP_meth_get_get_by_issuer_serial(
  134. \& const X509_LOOKUP_METHOD *method);
  135. \&
  136. \& typedef int (*X509_LOOKUP_get_by_fingerprint_fn)(X509_LOOKUP *ctx,
  137. \& X509_LOOKUP_TYPE type,
  138. \& const unsigned char* bytes,
  139. \& int len,
  140. \& X509_OBJECT *ret);
  141. \& int X509_LOOKUP_meth_set_get_by_fingerprint(X509_LOOKUP_METHOD *method,
  142. \& X509_LOOKUP_get_by_fingerprint_fn fn);
  143. \& X509_LOOKUP_get_by_fingerprint_fn X509_LOOKUP_meth_get_get_by_fingerprint(
  144. \& const X509_LOOKUP_METHOD *method);
  145. \&
  146. \& typedef int (*X509_LOOKUP_get_by_alias_fn)(X509_LOOKUP *ctx,
  147. \& X509_LOOKUP_TYPE type,
  148. \& const char *str,
  149. \& int len,
  150. \& X509_OBJECT *ret);
  151. \& int X509_LOOKUP_meth_set_get_by_alias(X509_LOOKUP_METHOD *method,
  152. \& X509_LOOKUP_get_by_alias_fn fn);
  153. \& X509_LOOKUP_get_by_alias_fn X509_LOOKUP_meth_get_get_by_alias(
  154. \& const X509_LOOKUP_METHOD *method);
  155. \&
  156. \& int X509_OBJECT_set1_X509(X509_OBJECT *a, X509 *obj);
  157. \& int X509_OBJECT_set1_X509_CRL(X509_OBJECT *a, X509_CRL *obj);
  158. .Ve
  159. .SH DESCRIPTION
  160. .IX Header "DESCRIPTION"
  161. The \fBX509_LOOKUP_METHOD\fR type is a structure used for the implementation of new
  162. X509_LOOKUP types. It provides a set of functions used by OpenSSL for the
  163. implementation of various X509 and X509_CRL lookup capabilities. One instance
  164. of an X509_LOOKUP_METHOD can be associated to many instantiations of an
  165. \&\fBX509_LOOKUP\fR structure.
  166. .PP
  167. \&\fBX509_LOOKUP_meth_new()\fR creates a new \fBX509_LOOKUP_METHOD\fR structure. It should
  168. be given a human-readable string containing a brief description of the lookup
  169. method.
  170. .PP
  171. \&\fBX509_LOOKUP_meth_free()\fR destroys a \fBX509_LOOKUP_METHOD\fR structure.
  172. If the argument is NULL, nothing is done.
  173. .PP
  174. \&\fBX509_LOOKUP_get_new_item()\fR and \fBX509_LOOKUP_set_new_item()\fR get and set the
  175. function that is called when an \fBX509_LOOKUP\fR object is created with
  176. \&\fBX509_LOOKUP_new()\fR. If an X509_LOOKUP_METHOD requires any per\-X509_LOOKUP
  177. specific data, the supplied new_item function should allocate this data and
  178. invoke \fBX509_LOOKUP_set_method_data\fR\|(3).
  179. .PP
  180. \&\fBX509_LOOKUP_get_free()\fR and \fBX509_LOOKUP_set_free()\fR get and set the function
  181. that is used to free any method data that was allocated and set from within
  182. new_item function.
  183. .PP
  184. \&\fBX509_LOOKUP_meth_get_init()\fR and \fBX509_LOOKUP_meth_set_init()\fR get and set the
  185. function that is used to initialize the method data that was set with
  186. \&\fBX509_LOOKUP_set_method_data\fR\|(3) as part of the new_item routine.
  187. .PP
  188. \&\fBX509_LOOKUP_meth_get_shutdown()\fR and \fBX509_LOOKUP_meth_set_shutdown()\fR get and set
  189. the function that is used to shut down the method data whose state was
  190. previously initialized in the init function.
  191. .PP
  192. \&\fBX509_LOOKUP_meth_get_ctrl()\fR and \fBX509_LOOKUP_meth_set_ctrl()\fR get and set a
  193. function to be used to handle arbitrary control commands issued by
  194. \&\fBX509_LOOKUP_ctrl()\fR. The control function is given the X509_LOOKUP
  195. \&\fBctx\fR, along with the arguments passed by X509_LOOKUP_ctrl. \fBcmd\fR is
  196. an arbitrary integer that defines some operation. \fBargc\fR is a pointer
  197. to an array of characters. \fBargl\fR is an integer. \fBret\fR, if set,
  198. points to a location where any return data should be written to. How
  199. \&\fBargc\fR and \fBargl\fR are used depends entirely on the control function.
  200. .PP
  201. \&\fBX509_LOOKUP_set_get_by_subject()\fR, \fBX509_LOOKUP_set_get_by_issuer_serial()\fR,
  202. \&\fBX509_LOOKUP_set_get_by_fingerprint()\fR, \fBX509_LOOKUP_set_get_by_alias()\fR set
  203. the functions used to retrieve an X509 or X509_CRL object by the object's
  204. subject, issuer, fingerprint, and alias respectively. These functions are given
  205. the X509_LOOKUP context, the type of the X509_OBJECT being requested, parameters
  206. related to the lookup, and an X509_OBJECT that will receive the requested
  207. object.
  208. .PP
  209. Implementations must add objects they find to the \fBX509_STORE\fR object
  210. using \fBX509_STORE_add_cert()\fR or \fBX509_STORE_add_crl()\fR. This increments
  211. its reference count. However, the \fBX509_STORE_CTX_get_by_subject\fR\|(3)
  212. function also increases the reference count which leads to one too
  213. many references being held. Therefore, applications should
  214. additionally call \fBX509_free()\fR or \fBX509_CRL_free()\fR to decrement the
  215. reference count again.
  216. .PP
  217. Implementations should also use either \fBX509_OBJECT_set1_X509()\fR or
  218. \&\fBX509_OBJECT_set1_X509_CRL()\fR to set the result. Note that this also
  219. increments the result's reference count.
  220. .PP
  221. Any method data that was created as a result of the new_item function
  222. set by \fBX509_LOOKUP_meth_set_new_item()\fR can be accessed with
  223. \&\fBX509_LOOKUP_get_method_data\fR\|(3). The \fBX509_STORE\fR object that owns the
  224. X509_LOOKUP may be accessed with \fBX509_LOOKUP_get_store\fR\|(3). Successful
  225. lookups should return 1, and unsuccessful lookups should return 0.
  226. .PP
  227. \&\fBX509_LOOKUP_get_get_by_subject()\fR, \fBX509_LOOKUP_get_get_by_issuer_serial()\fR,
  228. \&\fBX509_LOOKUP_get_get_by_fingerprint()\fR, \fBX509_LOOKUP_get_get_by_alias()\fR retrieve
  229. the function set by the corresponding setter.
  230. .SH "RETURN VALUES"
  231. .IX Header "RETURN VALUES"
  232. The \fBX509_LOOKUP_meth_set\fR functions return 1 on success or 0 on error.
  233. .PP
  234. The \fBX509_LOOKUP_meth_get\fR functions return the corresponding function
  235. pointers.
  236. .SH "SEE ALSO"
  237. .IX Header "SEE ALSO"
  238. \&\fBX509_STORE_CTX_get_by_subject\fR\|(3),
  239. \&\fBX509_STORE_new\fR\|(3), \fBSSL_CTX_set_cert_store\fR\|(3)
  240. .SH HISTORY
  241. .IX Header "HISTORY"
  242. The functions described here were added in OpenSSL 1.1.0i.
  243. .SH COPYRIGHT
  244. .IX Header "COPYRIGHT"
  245. Copyright 2018\-2024 The OpenSSL Project Authors. All Rights Reserved.
  246. .PP
  247. Licensed under the Apache License 2.0 (the "License"). You may not use
  248. this file except in compliance with the License. You can obtain a copy
  249. in the file LICENSE in the source distribution or at
  250. <https://www.openssl.org/source/license.html>.