X509_STORE_set_verify_cb_func.pod 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. =pod
  2. =head1 NAME
  3. X509_STORE_set_lookup_crls_cb,
  4. X509_STORE_set_verify_func,
  5. X509_STORE_get_cleanup,
  6. X509_STORE_set_cleanup,
  7. X509_STORE_get_lookup_crls,
  8. X509_STORE_set_lookup_crls,
  9. X509_STORE_get_lookup_certs,
  10. X509_STORE_set_lookup_certs,
  11. X509_STORE_get_check_policy,
  12. X509_STORE_set_check_policy,
  13. X509_STORE_get_cert_crl,
  14. X509_STORE_set_cert_crl,
  15. X509_STORE_get_check_crl,
  16. X509_STORE_set_check_crl,
  17. X509_STORE_get_get_crl,
  18. X509_STORE_set_get_crl,
  19. X509_STORE_get_check_revocation,
  20. X509_STORE_set_check_revocation,
  21. X509_STORE_get_check_issued,
  22. X509_STORE_set_check_issued,
  23. X509_STORE_CTX_get1_issuer,
  24. X509_STORE_get_get_issuer,
  25. X509_STORE_set_get_issuer,
  26. X509_STORE_CTX_get_verify,
  27. X509_STORE_set_verify,
  28. X509_STORE_get_verify_cb,
  29. X509_STORE_set_verify_cb_func, X509_STORE_set_verify_cb,
  30. X509_STORE_CTX_cert_crl_fn, X509_STORE_CTX_check_crl_fn,
  31. X509_STORE_CTX_check_issued_fn, X509_STORE_CTX_check_policy_fn,
  32. X509_STORE_CTX_check_revocation_fn, X509_STORE_CTX_cleanup_fn,
  33. X509_STORE_CTX_get_crl_fn, X509_STORE_CTX_get_issuer_fn,
  34. X509_STORE_CTX_lookup_certs_fn, X509_STORE_CTX_lookup_crls_fn
  35. - set verification callback
  36. =head1 SYNOPSIS
  37. #include <openssl/x509_vfy.h>
  38. typedef int (*X509_STORE_CTX_get_issuer_fn)(X509 **issuer,
  39. X509_STORE_CTX *ctx, X509 *x);
  40. typedef int (*X509_STORE_CTX_check_issued_fn)(X509_STORE_CTX *ctx,
  41. X509 *x, X509 *issuer);
  42. typedef int (*X509_STORE_CTX_check_revocation_fn)(X509_STORE_CTX *ctx);
  43. typedef int (*X509_STORE_CTX_get_crl_fn)(X509_STORE_CTX *ctx,
  44. X509_CRL **crl, X509 *x);
  45. typedef int (*X509_STORE_CTX_check_crl_fn)(X509_STORE_CTX *ctx, X509_CRL *crl);
  46. typedef int (*X509_STORE_CTX_cert_crl_fn)(X509_STORE_CTX *ctx,
  47. X509_CRL *crl, X509 *x);
  48. typedef int (*X509_STORE_CTX_check_policy_fn)(X509_STORE_CTX *ctx);
  49. typedef STACK_OF(X509) *(*X509_STORE_CTX_lookup_certs_fn)(X509_STORE_CTX *ctx,
  50. const X509_NAME *nm);
  51. typedef STACK_OF(X509_CRL) *(*X509_STORE_CTX_lookup_crls_fn)(const
  52. X509_STORE_CTX *ctx,
  53. const X509_NAME *nm);
  54. typedef int (*X509_STORE_CTX_cleanup_fn)(X509_STORE_CTX *ctx);
  55. void X509_STORE_set_verify_cb(X509_STORE *xs,
  56. X509_STORE_CTX_verify_cb verify_cb);
  57. X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(const X509_STORE_CTX *ctx);
  58. void X509_STORE_set_verify(X509_STORE *xs, X509_STORE_CTX_verify_fn verify);
  59. X509_STORE_CTX_verify_fn X509_STORE_CTX_get_verify(const X509_STORE_CTX *ctx);
  60. int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
  61. X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(const X509_STORE_CTX *ctx);
  62. void X509_STORE_set_get_issuer(X509_STORE *xs,
  63. X509_STORE_CTX_get_issuer_fn get_issuer);
  64. void X509_STORE_set_check_issued(X509_STORE *xs,
  65. X509_STORE_CTX_check_issued_fn check_issued);
  66. X509_STORE_CTX_check_issued_fn
  67. X509_STORE_get_check_issued(const X509_STORE_CTX *ctx);
  68. void X509_STORE_set_check_revocation(X509_STORE *xs,
  69. X509_STORE_CTX_check_revocation_fn check_revocation);
  70. X509_STORE_CTX_check_revocation_fn
  71. X509_STORE_get_check_revocation(const X509_STORE_CTX *ctx);
  72. void X509_STORE_set_get_crl(X509_STORE *xs,
  73. X509_STORE_CTX_get_crl_fn get_crl);
  74. X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(const X509_STORE_CTX *ctx);
  75. void X509_STORE_set_check_crl(X509_STORE *xs,
  76. X509_STORE_CTX_check_crl_fn check_crl);
  77. X509_STORE_CTX_check_crl_fn
  78. X509_STORE_get_check_crl(const X509_STORE_CTX *ctx);
  79. void X509_STORE_set_cert_crl(X509_STORE *xs,
  80. X509_STORE_CTX_cert_crl_fn cert_crl);
  81. X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(const X509_STORE_CTX *ctx);
  82. void X509_STORE_set_check_policy(X509_STORE *xs,
  83. X509_STORE_CTX_check_policy_fn check_policy);
  84. X509_STORE_CTX_check_policy_fn
  85. X509_STORE_get_check_policy(const X509_STORE_CTX *ctx);
  86. void X509_STORE_set_lookup_certs(X509_STORE *xs,
  87. X509_STORE_CTX_lookup_certs_fn lookup_certs);
  88. X509_STORE_CTX_lookup_certs_fn
  89. X509_STORE_get_lookup_certs(const X509_STORE_CTX *ctx);
  90. void X509_STORE_set_lookup_crls(X509_STORE *xs,
  91. X509_STORE_CTX_lookup_crls_fn lookup_crls);
  92. X509_STORE_CTX_lookup_crls_fn
  93. X509_STORE_get_lookup_crls(const X509_STORE_CTX *ctx);
  94. void X509_STORE_set_cleanup(X509_STORE *xs,
  95. X509_STORE_CTX_cleanup_fn cleanup);
  96. X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(const X509_STORE_CTX *ctx);
  97. /* Aliases */
  98. void X509_STORE_set_verify_cb_func(X509_STORE *st,
  99. X509_STORE_CTX_verify_cb verify_cb);
  100. void X509_STORE_set_verify_func(X509_STORE *xs,
  101. X509_STORE_CTX_verify_fn verify);
  102. void X509_STORE_set_lookup_crls_cb(X509_STORE *xs,
  103. X509_STORE_CTX_lookup_crls_fn lookup_crls);
  104. =head1 DESCRIPTION
  105. X509_STORE_set_verify_cb() sets the verification callback of I<xs> to
  106. I<verify_cb> overwriting the previous callback.
  107. The callback assigned with this function becomes a default for the one
  108. that can be assigned directly to the corresponding B<X509_STORE_CTX>,
  109. please see L<X509_STORE_CTX_set_verify_cb(3)> for further information.
  110. X509_STORE_set_verify() sets the final chain verification function for
  111. I<xs> to I<verify>.
  112. Its purpose is to go through the chain of certificates and check that
  113. all signatures are valid and that the current time is within the
  114. limits of each certificate's first and last validity time.
  115. The final chain verification functions must return 0 on failure and 1
  116. on success.
  117. I<If no chain verification function is provided, the internal default
  118. function will be used instead.>
  119. X509_STORE_CTX_get1_issuer() tries to find a certificate from the I<store>
  120. component of I<ctx> that has a subject name matching the issuer name of I<x>
  121. and is accepted by the I<check_issued> function in I<ctx>.
  122. On success it assigns to I<*issuer> the first match that has a suitable validity
  123. period or otherwise has the latest expiration date of all matching certificates.
  124. If the function returns 1 the caller is responsible for freeing I<*issuer>.
  125. Note that this search does not support backtracking.
  126. X509_STORE_set_get_issuer() sets the function I<get_issuer> that is used
  127. to get the "best" candidate issuer certificate of the given certificate I<x>.
  128. When such a certificate is found, I<get_issuer> must up-ref and assign it
  129. to I<*issuer> and then return 1.
  130. Otherwise I<get_issuer> must return 0 if not found and -1 (or 0) on failure.
  131. If X509_STORE_set_get_issuer() is not used or I<get_issuer> is NULL
  132. then X509_STORE_CTX_get1_issuer() is used as the default implementation.
  133. X509_STORE_set_check_issued() sets the function to check that a given
  134. certificate I<x> is issued by the issuer certificate I<issuer>.
  135. This function must return 0 on failure (among others if I<x> hasn't
  136. been issued with I<issuer>) and 1 on success.
  137. I<If no function to get the issuer is provided, the internal default
  138. function will be used instead.>
  139. X509_STORE_set_check_revocation() sets the revocation checking
  140. function.
  141. Its purpose is to look through the final chain and check the
  142. revocation status for each certificate.
  143. It must return 0 on failure and 1 on success.
  144. I<If no function to get the issuer is provided, the internal default
  145. function will be used instead.>
  146. X509_STORE_set_get_crl() sets the function to get the crl for a given
  147. certificate I<x>.
  148. When found, the crl must be assigned to I<*crl>.
  149. This function must return 0 on failure and 1 on success.
  150. I<If no function to get the issuer is provided, the internal default
  151. function will be used instead.>
  152. X509_STORE_set_check_crl() sets the function to check the validity of
  153. the given I<crl>.
  154. This function must return 0 on failure and 1 on success.
  155. I<If no function to get the issuer is provided, the internal default
  156. function will be used instead.>
  157. X509_STORE_set_cert_crl() sets the function to check the revocation
  158. status of the given certificate I<x> against the given I<crl>.
  159. This function must return 0 on failure and 1 on success.
  160. I<If no function to get the issuer is provided, the internal default
  161. function will be used instead.>
  162. X509_STORE_set_check_policy() sets the function to check the policies
  163. of all the certificates in the final chain..
  164. This function must return 0 on failure and 1 on success.
  165. I<If no function to get the issuer is provided, the internal default
  166. function will be used instead.>
  167. X509_STORE_set_lookup_certs() and X509_STORE_set_lookup_crls() set the
  168. functions to look up all the certs or all the CRLs that match the
  169. given name I<nm>.
  170. These functions return NULL on failure and a pointer to a stack of
  171. certificates (B<X509>) or to a stack of CRLs (B<X509_CRL>) on
  172. success.
  173. I<If no function to get the issuer is provided, the internal default
  174. function will be used instead.>
  175. X509_STORE_set_cleanup() sets the final cleanup function, which is
  176. called when the context (B<X509_STORE_CTX>) is being torn down.
  177. This function doesn't return any value.
  178. I<If no function to get the issuer is provided, the internal default
  179. function will be used instead.>
  180. X509_STORE_get_verify_cb(), X509_STORE_CTX_get_verify(),
  181. X509_STORE_get_get_issuer(), X509_STORE_get_check_issued(),
  182. X509_STORE_get_check_revocation(), X509_STORE_get_get_crl(),
  183. X509_STORE_get_check_crl(), X509_STORE_set_verify(),
  184. X509_STORE_set_get_issuer(), X509_STORE_get_cert_crl(),
  185. X509_STORE_get_check_policy(), X509_STORE_get_lookup_certs(),
  186. X509_STORE_get_lookup_crls() and X509_STORE_get_cleanup() all return
  187. the function pointer assigned with X509_STORE_set_check_issued(),
  188. X509_STORE_set_check_revocation(), X509_STORE_set_get_crl(),
  189. X509_STORE_set_check_crl(), X509_STORE_set_cert_crl(),
  190. X509_STORE_set_check_policy(), X509_STORE_set_lookup_certs(),
  191. X509_STORE_set_lookup_crls() and X509_STORE_set_cleanup(), or NULL if
  192. no assignment has been made.
  193. X509_STORE_set_verify_cb_func(), X509_STORE_set_verify_func() and
  194. X509_STORE_set_lookup_crls_cb() are aliases for
  195. X509_STORE_set_verify_cb(), X509_STORE_set_verify() and
  196. X509_STORE_set_lookup_crls, available as macros for backward
  197. compatibility.
  198. =head1 NOTES
  199. All the callbacks from a B<X509_STORE> are inherited by the
  200. corresponding B<X509_STORE_CTX> structure when it is initialized.
  201. See L<X509_STORE_CTX_set_verify_cb(3)> for further details.
  202. =head1 BUGS
  203. The macro version of this function was the only one available before
  204. OpenSSL 1.0.0.
  205. =head1 RETURN VALUES
  206. The X509_STORE_set_*() functions do not return a value.
  207. The X509_STORE_get_*() functions return a pointer of the appropriate
  208. function type.
  209. X509_STORE_CTX_get1_issuer() returns
  210. 1 if a suitable certificate is found, 0 if not found, -1 on other error.
  211. =head1 SEE ALSO
  212. L<X509_STORE_CTX_set_verify_cb(3)>, L<X509_STORE_CTX_get0_chain(3)>,
  213. L<X509_STORE_CTX_verify_cb(3)>, L<X509_STORE_CTX_verify_fn(3)>,
  214. L<CMS_verify(3)>
  215. =head1 HISTORY
  216. The X509_STORE_set_verify_cb() function was added in OpenSSL 1.0.0.
  217. The functions
  218. X509_STORE_set_verify_cb(), X509_STORE_get_verify_cb(),
  219. X509_STORE_set_verify(), X509_STORE_CTX_get_verify(),
  220. X509_STORE_set_get_issuer(), X509_STORE_get_get_issuer(),
  221. X509_STORE_set_check_issued(), X509_STORE_get_check_issued(),
  222. X509_STORE_set_check_revocation(), X509_STORE_get_check_revocation(),
  223. X509_STORE_set_get_crl(), X509_STORE_get_get_crl(),
  224. X509_STORE_set_check_crl(), X509_STORE_get_check_crl(),
  225. X509_STORE_set_cert_crl(), X509_STORE_get_cert_crl(),
  226. X509_STORE_set_check_policy(), X509_STORE_get_check_policy(),
  227. X509_STORE_set_lookup_certs(), X509_STORE_get_lookup_certs(),
  228. X509_STORE_set_lookup_crls(), X509_STORE_get_lookup_crls(),
  229. X509_STORE_set_cleanup() and X509_STORE_get_cleanup()
  230. were added in OpenSSL 1.1.0.
  231. =head1 COPYRIGHT
  232. Copyright 2009-2021 The OpenSSL Project Authors. All Rights Reserved.
  233. Licensed under the Apache License 2.0 (the "License"). You may not use
  234. this file except in compliance with the License. You can obtain a copy
  235. in the file LICENSE in the source distribution or at
  236. L<https://www.openssl.org/source/license.html>.
  237. =cut