OSSL_STORE_open.3ossl 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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 "OSSL_STORE_OPEN 3ossl"
  58. .TH OSSL_STORE_OPEN 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. OSSL_STORE_CTX, OSSL_STORE_post_process_info_fn,
  65. OSSL_STORE_open, OSSL_STORE_open_ex,
  66. OSSL_STORE_ctrl, OSSL_STORE_load, OSSL_STORE_eof, OSSL_STORE_delete,
  67. OSSL_STORE_error, OSSL_STORE_close
  68. \&\- Types and functions to read objects from a URI
  69. .SH SYNOPSIS
  70. .IX Header "SYNOPSIS"
  71. .Vb 1
  72. \& #include <openssl/store.h>
  73. \&
  74. \& typedef struct ossl_store_ctx_st OSSL_STORE_CTX;
  75. \&
  76. \& typedef OSSL_STORE_INFO *(*OSSL_STORE_post_process_info_fn)(OSSL_STORE_INFO *,
  77. \& void *);
  78. \&
  79. \& OSSL_STORE_CTX *OSSL_STORE_open(const char *uri, const UI_METHOD *ui_method,
  80. \& void *ui_data,
  81. \& OSSL_STORE_post_process_info_fn post_process,
  82. \& void *post_process_data);
  83. \& OSSL_STORE_CTX *
  84. \& OSSL_STORE_open_ex(const char *uri, OSSL_LIB_CTX *libctx, const char *propq,
  85. \& const UI_METHOD *ui_method, void *ui_data,
  86. \& const OSSL_PARAM params[],
  87. \& OSSL_STORE_post_process_info_fn post_process,
  88. \& void *post_process_data);
  89. \&
  90. \& OSSL_STORE_INFO *OSSL_STORE_load(OSSL_STORE_CTX *ctx);
  91. \& int OSSL_STORE_eof(OSSL_STORE_CTX *ctx);
  92. \& int OSSL_STORE_delete(const char *uri, OSSL_LIB_CTX *libctx, const char *propq,
  93. \& const UI_METHOD *ui_method, void *ui_data,
  94. \& const OSSL_PARAM params[]);
  95. \& int OSSL_STORE_error(OSSL_STORE_CTX *ctx);
  96. \& int OSSL_STORE_close(OSSL_STORE_CTX *ctx);
  97. .Ve
  98. .PP
  99. The following function has been deprecated since OpenSSL 3.0, and can be
  100. hidden entirely by defining \fBOPENSSL_API_COMPAT\fR with a suitable version value,
  101. see \fBopenssl_user_macros\fR\|(7):
  102. .PP
  103. .Vb 1
  104. \& int OSSL_STORE_ctrl(OSSL_STORE_CTX *ctx, int cmd, ... /* args */);
  105. .Ve
  106. .SH DESCRIPTION
  107. .IX Header "DESCRIPTION"
  108. These functions help the application to fetch supported objects (see
  109. "SUPPORTED OBJECTS" in \fBOSSL_STORE_INFO\fR\|(3) for information on which those are)
  110. from a given URI.
  111. The general method to do so is to "open" the URI using \fBOSSL_STORE_open()\fR,
  112. read each available and supported object using \fBOSSL_STORE_load()\fR as long as
  113. \&\fBOSSL_STORE_eof()\fR hasn't been reached, and finish it off with \fBOSSL_STORE_close()\fR.
  114. .PP
  115. The retrieved information is stored in a \fBOSSL_STORE_INFO\fR, which is further
  116. described in \fBOSSL_STORE_INFO\fR\|(3).
  117. .SS Types
  118. .IX Subsection "Types"
  119. \&\fBOSSL_STORE_CTX\fR is a context variable that holds all the internal
  120. information for \fBOSSL_STORE_open()\fR, \fBOSSL_STORE_open_ex()\fR,
  121. \&\fBOSSL_STORE_load()\fR, \fBOSSL_STORE_eof()\fR and \fBOSSL_STORE_close()\fR to work
  122. together.
  123. .SS Functions
  124. .IX Subsection "Functions"
  125. \&\fBOSSL_STORE_open_ex()\fR takes a uri or path \fIuri\fR, password UI method
  126. \&\fIui_method\fR with associated data \fIui_data\fR, and post processing
  127. callback \fIpost_process\fR with associated data \fIpost_process_data\fR,
  128. a library context \fIlibctx\fR with an associated property query \fIpropq\fR,
  129. and opens a channel to the data located at the URI and returns a
  130. \&\fBOSSL_STORE_CTX\fR with all necessary internal information.
  131. The given \fIui_method\fR and \fIui_data\fR will be reused by all
  132. functions that use \fBOSSL_STORE_CTX\fR when interaction is needed,
  133. for instance to provide a password.
  134. The auxiliary \fBOSSL_PARAM\fR\|(3) parameters in \fIparams\fR can be set to further
  135. modify the store operation.
  136. The given \fIpost_process\fR and \fIpost_process_data\fR will be reused by
  137. \&\fBOSSL_STORE_load()\fR to manipulate or drop the value to be returned.
  138. The \fIpost_process\fR function drops values by returning NULL, which
  139. will cause \fBOSSL_STORE_load()\fR to start its process over with loading
  140. the next object, until \fIpost_process\fR returns something other than
  141. NULL, or the end of data is reached as indicated by \fBOSSL_STORE_eof()\fR.
  142. .PP
  143. \&\fBOSSL_STORE_open()\fR is similar to \fBOSSL_STORE_open_ex()\fR but uses NULL for
  144. the \fIparams\fR, the library context \fIlibctx\fR and property query \fIpropq\fR.
  145. .PP
  146. \&\fBOSSL_STORE_ctrl()\fR takes a \fBOSSL_STORE_CTX\fR, and command number \fIcmd\fR and
  147. more arguments not specified here.
  148. The available loader specific command numbers and arguments they each
  149. take depends on the loader that's used and is documented together with
  150. that loader.
  151. .PP
  152. There are also global controls available:
  153. .IP \fBOSSL_STORE_C_USE_SECMEM\fR 4
  154. .IX Item "OSSL_STORE_C_USE_SECMEM"
  155. Controls if the loader should attempt to use secure memory for any
  156. allocated \fBOSSL_STORE_INFO\fR and its contents.
  157. This control expects one argument, a pointer to an \fIint\fR that is expected to
  158. have the value 1 (yes) or 0 (no).
  159. Any other value is an error.
  160. .PP
  161. \&\fBOSSL_STORE_load()\fR takes a \fBOSSL_STORE_CTX\fR and tries to load the next
  162. available object and return it wrapped with \fBOSSL_STORE_INFO\fR.
  163. .PP
  164. \&\fBOSSL_STORE_delete()\fR deletes the object identified by \fIuri\fR.
  165. .PP
  166. \&\fBOSSL_STORE_eof()\fR takes a \fBOSSL_STORE_CTX\fR and checks if we've reached the end
  167. of data.
  168. .PP
  169. \&\fBOSSL_STORE_error()\fR takes a \fBOSSL_STORE_CTX\fR and checks if an error occurred in
  170. the last \fBOSSL_STORE_load()\fR call.
  171. Note that it may still be meaningful to try and load more objects, unless
  172. \&\fBOSSL_STORE_eof()\fR shows that the end of data has been reached.
  173. .PP
  174. \&\fBOSSL_STORE_close()\fR takes a \fBOSSL_STORE_CTX\fR, closes the channel that was opened
  175. by \fBOSSL_STORE_open()\fR and frees all other information that was stored in the
  176. \&\fBOSSL_STORE_CTX\fR, as well as the \fBOSSL_STORE_CTX\fR itself.
  177. If \fIctx\fR is NULL it does nothing.
  178. .SH NOTES
  179. .IX Header "NOTES"
  180. A string without a scheme prefix (that is, a non-URI string) is
  181. implicitly interpreted as using the \fIfile:\fR scheme.
  182. .PP
  183. There are some tools that can be used together with
  184. \&\fBOSSL_STORE_open()\fR to determine if any failure is caused by an unparsable
  185. URI, or if it's a different error (such as memory allocation
  186. failures); if the URI was parsable but the scheme unregistered, the
  187. top error will have the reason \f(CW\*(C`OSSL_STORE_R_UNREGISTERED_SCHEME\*(C'\fR.
  188. .PP
  189. These functions make no direct assumption regarding the pass phrase received
  190. from the password callback.
  191. The loaders may make assumptions, however.
  192. For example, the \fBfile:\fR scheme loader inherits the assumptions made by
  193. OpenSSL functionality that handles the different file types; this is mostly
  194. relevant for PKCS#12 objects.
  195. See \fBpassphrase\-encoding\fR\|(7) for further information.
  196. .SH "RETURN VALUES"
  197. .IX Header "RETURN VALUES"
  198. \&\fBOSSL_STORE_open()\fR returns a pointer to a \fBOSSL_STORE_CTX\fR on success, or
  199. NULL on failure.
  200. .PP
  201. \&\fBOSSL_STORE_load()\fR returns a pointer to a \fBOSSL_STORE_INFO\fR on success, or NULL
  202. on error or when end of data is reached.
  203. Use \fBOSSL_STORE_error()\fR and \fBOSSL_STORE_eof()\fR to determine the meaning of a
  204. returned NULL.
  205. .PP
  206. \&\fBOSSL_STORE_eof()\fR returns 1 if the end of data has been reached
  207. or an error occurred, 0 otherwise.
  208. .PP
  209. \&\fBOSSL_STORE_error()\fR returns 1 if an error occurred in an \fBOSSL_STORE_load()\fR call,
  210. otherwise 0.
  211. .PP
  212. \&\fBOSSL_STORE_delete()\fR, \fBOSSL_STORE_ctrl()\fR and \fBOSSL_STORE_close()\fR return 1 on
  213. success, or 0 on failure.
  214. .SH "SEE ALSO"
  215. .IX Header "SEE ALSO"
  216. \&\fBossl_store\fR\|(7), \fBOSSL_STORE_INFO\fR\|(3), \fBOSSL_STORE_register_loader\fR\|(3),
  217. \&\fBpassphrase\-encoding\fR\|(7)
  218. .SH HISTORY
  219. .IX Header "HISTORY"
  220. \&\fBOSSL_STORE_delete()\fR was added in OpenSSL 3.2.
  221. .PP
  222. \&\fBOSSL_STORE_open_ex()\fR was added in OpenSSL 3.0.
  223. .PP
  224. \&\fBOSSL_STORE_CTX\fR, \fBOSSL_STORE_post_process_info_fn()\fR, \fBOSSL_STORE_open()\fR,
  225. \&\fBOSSL_STORE_ctrl()\fR, \fBOSSL_STORE_load()\fR, \fBOSSL_STORE_eof()\fR and \fBOSSL_STORE_close()\fR
  226. were added in OpenSSL 1.1.1.
  227. .PP
  228. Handling of NULL \fIctx\fR argument for \fBOSSL_STORE_close()\fR
  229. was introduced in OpenSSL 1.1.1h.
  230. .PP
  231. \&\fBOSSL_STORE_ctrl()\fR and \fBOSSL_STORE_vctrl()\fR were deprecated in OpenSSL 3.0.
  232. .SH COPYRIGHT
  233. .IX Header "COPYRIGHT"
  234. Copyright 2016\-2023 The OpenSSL Project Authors. All Rights Reserved.
  235. .PP
  236. Licensed under the Apache License 2.0 (the "License"). You may not use
  237. this file except in compliance with the License. You can obtain a copy
  238. in the file LICENSE in the source distribution or at
  239. <https://www.openssl.org/source/license.html>.