OPENSSL_init_crypto.3ossl 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .nr rF 0
  58. .if \n(.g .if rF .nr rF 1
  59. .if (\n(rF:(\n(.g==0)) \{\
  60. . if \nF \{\
  61. . de IX
  62. . tm Index:\\$1\t\\n%\t"\\$2"
  63. ..
  64. . if !\nF==2 \{\
  65. . nr % 0
  66. . nr F 2
  67. . \}
  68. . \}
  69. .\}
  70. .rr rF
  71. .\"
  72. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  73. .\" Fear. Run. Save yourself. No user-serviceable parts.
  74. . \" fudge factors for nroff and troff
  75. .if n \{\
  76. . ds #H 0
  77. . ds #V .8m
  78. . ds #F .3m
  79. . ds #[ \f1
  80. . ds #] \fP
  81. .\}
  82. .if t \{\
  83. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  84. . ds #V .6m
  85. . ds #F 0
  86. . ds #[ \&
  87. . ds #] \&
  88. .\}
  89. . \" simple accents for nroff and troff
  90. .if n \{\
  91. . ds ' \&
  92. . ds ` \&
  93. . ds ^ \&
  94. . ds , \&
  95. . ds ~ ~
  96. . ds /
  97. .\}
  98. .if t \{\
  99. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  100. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  101. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  102. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  103. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  104. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  105. .\}
  106. . \" troff and (daisy-wheel) nroff accents
  107. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  108. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  109. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  110. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  111. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  112. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  113. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  114. .ds ae a\h'-(\w'a'u*4/10)'e
  115. .ds Ae A\h'-(\w'A'u*4/10)'E
  116. . \" corrections for vroff
  117. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  118. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  119. . \" for low resolution devices (crt and lpr)
  120. .if \n(.H>23 .if \n(.V>19 \
  121. \{\
  122. . ds : e
  123. . ds 8 ss
  124. . ds o a
  125. . ds d- d\h'-1'\(ga
  126. . ds D- D\h'-1'\(hy
  127. . ds th \o'bp'
  128. . ds Th \o'LP'
  129. . ds ae ae
  130. . ds Ae AE
  131. .\}
  132. .rm #[ #] #H #V #F C
  133. .\" ========================================================================
  134. .\"
  135. .IX Title "OPENSSL_INIT_CRYPTO 3ossl"
  136. .TH OPENSSL_INIT_CRYPTO 3ossl "2024-09-03" "3.3.2" "OpenSSL"
  137. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  138. .\" way too many mistakes in technical documents.
  139. .if n .ad l
  140. .nh
  141. .SH "NAME"
  142. OPENSSL_INIT_new, OPENSSL_INIT_set_config_filename,
  143. OPENSSL_INIT_set_config_appname, OPENSSL_INIT_set_config_file_flags,
  144. OPENSSL_INIT_free, OPENSSL_init_crypto, OPENSSL_cleanup, OPENSSL_atexit,
  145. OPENSSL_thread_stop_ex, OPENSSL_thread_stop \- OpenSSL initialisation
  146. and deinitialisation functions
  147. .SH "SYNOPSIS"
  148. .IX Header "SYNOPSIS"
  149. .Vb 1
  150. \& #include <openssl/crypto.h>
  151. \&
  152. \& void OPENSSL_cleanup(void);
  153. \& int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
  154. \& int OPENSSL_atexit(void (*handler)(void));
  155. \& void OPENSSL_thread_stop_ex(OSSL_LIB_CTX *ctx);
  156. \& void OPENSSL_thread_stop(void);
  157. \&
  158. \& OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void);
  159. \& int OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *init,
  160. \& const char* filename);
  161. \& int OPENSSL_INIT_set_config_file_flags(OPENSSL_INIT_SETTINGS *init,
  162. \& unsigned long flags);
  163. \& int OPENSSL_INIT_set_config_appname(OPENSSL_INIT_SETTINGS *init,
  164. \& const char* name);
  165. \& void OPENSSL_INIT_free(OPENSSL_INIT_SETTINGS *init);
  166. .Ve
  167. .SH "DESCRIPTION"
  168. .IX Header "DESCRIPTION"
  169. During normal operation OpenSSL (libcrypto) will allocate various resources at
  170. start up that must, subsequently, be freed on close down of the library.
  171. Additionally some resources are allocated on a per thread basis (if the
  172. application is multi-threaded), and these resources must be freed prior to the
  173. thread closing.
  174. .PP
  175. As of version 1.1.0 OpenSSL will automatically allocate all resources that it
  176. needs so no explicit initialisation is required. Similarly it will also
  177. automatically deinitialise as required.
  178. .PP
  179. However, there may be situations when explicit initialisation is desirable or
  180. needed, for example when some nondefault initialisation is required. The
  181. function \fBOPENSSL_init_crypto()\fR can be used for this purpose for
  182. libcrypto (see also \fBOPENSSL_init_ssl\fR\|(3) for the libssl
  183. equivalent).
  184. .PP
  185. Numerous internal OpenSSL functions call \fBOPENSSL_init_crypto()\fR.
  186. Therefore, in order to perform nondefault initialisation,
  187. \&\fBOPENSSL_init_crypto()\fR \s-1MUST\s0 be called by application code prior to
  188. any other OpenSSL function calls.
  189. .PP
  190. The \fBopts\fR parameter specifies which aspects of libcrypto should be
  191. initialised. Valid options are:
  192. .IP "\s-1OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS\s0" 4
  193. .IX Item "OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS"
  194. Suppress automatic loading of the libcrypto error strings. This option is
  195. not a default option. Once selected subsequent calls to
  196. \&\fBOPENSSL_init_crypto()\fR with the option
  197. \&\fB\s-1OPENSSL_INIT_LOAD_CRYPTO_STRINGS\s0\fR will be ignored.
  198. .IP "\s-1OPENSSL_INIT_LOAD_CRYPTO_STRINGS\s0" 4
  199. .IX Item "OPENSSL_INIT_LOAD_CRYPTO_STRINGS"
  200. Automatic loading of the libcrypto error strings. With this option the
  201. library will automatically load the libcrypto error strings.
  202. This option is a default option. Once selected subsequent calls to
  203. \&\fBOPENSSL_init_crypto()\fR with the option
  204. \&\fB\s-1OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS\s0\fR will be ignored.
  205. .IP "\s-1OPENSSL_INIT_ADD_ALL_CIPHERS\s0" 4
  206. .IX Item "OPENSSL_INIT_ADD_ALL_CIPHERS"
  207. With this option the library will automatically load and make available all
  208. libcrypto ciphers. This option is a default option. Once selected subsequent
  209. calls to \fBOPENSSL_init_crypto()\fR with the option
  210. \&\fB\s-1OPENSSL_INIT_NO_ADD_ALL_CIPHERS\s0\fR will be ignored.
  211. .IP "\s-1OPENSSL_INIT_ADD_ALL_DIGESTS\s0" 4
  212. .IX Item "OPENSSL_INIT_ADD_ALL_DIGESTS"
  213. With this option the library will automatically load and make available all
  214. libcrypto digests. This option is a default option. Once selected subsequent
  215. calls to \fBOPENSSL_init_crypto()\fR with the option
  216. \&\fB\s-1OPENSSL_INIT_NO_ADD_ALL_DIGESTS\s0\fR will be ignored.
  217. .IP "\s-1OPENSSL_INIT_NO_ADD_ALL_CIPHERS\s0" 4
  218. .IX Item "OPENSSL_INIT_NO_ADD_ALL_CIPHERS"
  219. With this option the library will suppress automatic loading of libcrypto
  220. ciphers. This option is not a default option. Once selected subsequent
  221. calls to \fBOPENSSL_init_crypto()\fR with the option
  222. \&\fB\s-1OPENSSL_INIT_ADD_ALL_CIPHERS\s0\fR will be ignored.
  223. .IP "\s-1OPENSSL_INIT_NO_ADD_ALL_DIGESTS\s0" 4
  224. .IX Item "OPENSSL_INIT_NO_ADD_ALL_DIGESTS"
  225. With this option the library will suppress automatic loading of libcrypto
  226. digests. This option is not a default option. Once selected subsequent
  227. calls to \fBOPENSSL_init_crypto()\fR with the option
  228. \&\fB\s-1OPENSSL_INIT_ADD_ALL_DIGESTS\s0\fR will be ignored.
  229. .IP "\s-1OPENSSL_INIT_LOAD_CONFIG\s0" 4
  230. .IX Item "OPENSSL_INIT_LOAD_CONFIG"
  231. With this option an OpenSSL configuration file will be automatically loaded and
  232. used by calling \fBOPENSSL_config()\fR. This is a default option.
  233. Note that in OpenSSL 1.1.1 this was the default for libssl but not for
  234. libcrypto (see \fBOPENSSL_init_ssl\fR\|(3) for further details about libssl
  235. initialisation).
  236. In OpenSSL 1.1.0 this was a nondefault option for both libssl and libcrypto.
  237. See the description of \fBOPENSSL_INIT_new()\fR, below.
  238. .IP "\s-1OPENSSL_INIT_NO_LOAD_CONFIG\s0" 4
  239. .IX Item "OPENSSL_INIT_NO_LOAD_CONFIG"
  240. With this option the loading of OpenSSL configuration files will be suppressed.
  241. It is the equivalent of calling \fBOPENSSL_no_config()\fR. This is not a default
  242. option.
  243. .IP "\s-1OPENSSL_INIT_ASYNC\s0" 4
  244. .IX Item "OPENSSL_INIT_ASYNC"
  245. With this option the library with automatically initialise the libcrypto async
  246. sub-library (see \fBASYNC_start_job\fR\|(3)). This is a default option.
  247. .IP "\s-1OPENSSL_INIT_ENGINE_RDRAND\s0" 4
  248. .IX Item "OPENSSL_INIT_ENGINE_RDRAND"
  249. With this option the library will automatically load and initialise the
  250. \&\s-1RDRAND\s0 engine (if available). This not a default option and is deprecated
  251. in OpenSSL 3.0.
  252. .IP "\s-1OPENSSL_INIT_ENGINE_DYNAMIC\s0" 4
  253. .IX Item "OPENSSL_INIT_ENGINE_DYNAMIC"
  254. With this option the library will automatically load and initialise the
  255. dynamic engine. This not a default option and is deprecated
  256. in OpenSSL 3.0.
  257. .IP "\s-1OPENSSL_INIT_ENGINE_OPENSSL\s0" 4
  258. .IX Item "OPENSSL_INIT_ENGINE_OPENSSL"
  259. With this option the library will automatically load and initialise the
  260. openssl engine. This not a default option and is deprecated
  261. in OpenSSL 3.0.
  262. .IP "\s-1OPENSSL_INIT_ENGINE_CRYPTODEV\s0" 4
  263. .IX Item "OPENSSL_INIT_ENGINE_CRYPTODEV"
  264. With this option the library will automatically load and initialise the
  265. cryptodev engine (if available). This not a default option and is deprecated
  266. in OpenSSL 3.0.
  267. .IP "\s-1OPENSSL_INIT_ENGINE_CAPI\s0" 4
  268. .IX Item "OPENSSL_INIT_ENGINE_CAPI"
  269. With this option the library will automatically load and initialise the
  270. \&\s-1CAPI\s0 engine (if available). This not a default option and is deprecated
  271. in OpenSSL 3.0.
  272. .IP "\s-1OPENSSL_INIT_ENGINE_PADLOCK\s0" 4
  273. .IX Item "OPENSSL_INIT_ENGINE_PADLOCK"
  274. With this option the library will automatically load and initialise the
  275. padlock engine (if available). This not a default option and is deprecated
  276. in OpenSSL 3.0.
  277. .IP "\s-1OPENSSL_INIT_ENGINE_AFALG\s0" 4
  278. .IX Item "OPENSSL_INIT_ENGINE_AFALG"
  279. With this option the library will automatically load and initialise the
  280. \&\s-1AFALG\s0 engine. This not a default option and is deprecated
  281. in OpenSSL 3.0.
  282. .IP "\s-1OPENSSL_INIT_ENGINE_ALL_BUILTIN\s0" 4
  283. .IX Item "OPENSSL_INIT_ENGINE_ALL_BUILTIN"
  284. With this option the library will automatically load and initialise all the
  285. built in engines listed above with the exception of the openssl and afalg
  286. engines. This not a default option and is deprecated
  287. in OpenSSL 3.0.
  288. .IP "\s-1OPENSSL_INIT_ATFORK\s0" 4
  289. .IX Item "OPENSSL_INIT_ATFORK"
  290. With this option the library will register its fork handlers.
  291. See \fBOPENSSL_fork_prepare\fR\|(3) for details.
  292. .IP "\s-1OPENSSL_INIT_NO_ATEXIT\s0" 4
  293. .IX Item "OPENSSL_INIT_NO_ATEXIT"
  294. By default OpenSSL will attempt to clean itself up when the process exits via an
  295. \&\*(L"atexit\*(R" handler. Using this option suppresses that behaviour. This means that
  296. the application will have to clean up OpenSSL explicitly using
  297. \&\fBOPENSSL_cleanup()\fR.
  298. .PP
  299. Multiple options may be combined together in a single call to
  300. \&\fBOPENSSL_init_crypto()\fR. For example:
  301. .PP
  302. .Vb 2
  303. \& OPENSSL_init_crypto(OPENSSL_INIT_NO_ADD_ALL_CIPHERS
  304. \& | OPENSSL_INIT_NO_ADD_ALL_DIGESTS, NULL);
  305. .Ve
  306. .PP
  307. The \fBOPENSSL_cleanup()\fR function deinitialises OpenSSL (both libcrypto
  308. and libssl). All resources allocated by OpenSSL are freed. Typically there
  309. should be no need to call this function directly as it is initiated
  310. automatically on application exit. This is done via the standard C library
  311. \&\fBatexit()\fR function. In the event that the application will close in a manner
  312. that will not call the registered \fBatexit()\fR handlers then the application should
  313. call \fBOPENSSL_cleanup()\fR directly. Developers of libraries using OpenSSL
  314. are discouraged from calling this function and should instead, typically, rely
  315. on auto-deinitialisation. This is to avoid error conditions where both an
  316. application and a library it depends on both use OpenSSL, and the library
  317. deinitialises it before the application has finished using it.
  318. .PP
  319. Once \fBOPENSSL_cleanup()\fR has been called the library cannot be reinitialised.
  320. Attempts to call \fBOPENSSL_init_crypto()\fR will fail and an \s-1ERR_R_INIT_FAIL\s0 error
  321. will be added to the error stack. Note that because initialisation has failed
  322. OpenSSL error strings will not be available, only an error code. This code can
  323. be put through the openssl errstr command line application to produce a human
  324. readable error (see \fBopenssl\-errstr\fR\|(1)).
  325. .PP
  326. The \fBOPENSSL_atexit()\fR function enables the registration of a
  327. function to be called during \fBOPENSSL_cleanup()\fR. Stop handlers are
  328. called after deinitialisation of resources local to a thread, but before other
  329. process wide resources are freed. In the event that multiple stop handlers are
  330. registered, no guarantees are made about the order of execution.
  331. .PP
  332. The \fBOPENSSL_thread_stop_ex()\fR function deallocates resources associated
  333. with the current thread for the given \s-1OSSL_LIB_CTX\s0 \fBctx\fR. The \fBctx\fR parameter
  334. can be \s-1NULL\s0 in which case the default \s-1OSSL_LIB_CTX\s0 is used.
  335. .PP
  336. Typically, this function will be called automatically by the library when
  337. the thread exits as long as the \s-1OSSL_LIB_CTX\s0 has not been freed before the thread
  338. exits. If \fBOSSL_LIB_CTX_free()\fR is called OPENSSL_thread_stop_ex will be called
  339. automatically for the current thread (but not any other threads that may have
  340. used this \s-1OSSL_LIB_CTX\s0).
  341. .PP
  342. OPENSSL_thread_stop_ex should be called on all threads that will exit after the
  343. \&\s-1OSSL_LIB_CTX\s0 is freed.
  344. Typically this is not necessary for the default \s-1OSSL_LIB_CTX\s0 (because all
  345. resources are cleaned up on library exit) except if thread local resources
  346. should be freed before library exit, or under the circumstances described in
  347. the \s-1NOTES\s0 section below.
  348. .PP
  349. \&\fBOPENSSL_thread_stop()\fR is the same as \fBOPENSSL_thread_stop_ex()\fR except that the
  350. default \s-1OSSL_LIB_CTX\s0 is always used.
  351. .PP
  352. The \fB\s-1OPENSSL_INIT_LOAD_CONFIG\s0\fR flag will load a configuration file, as with
  353. \&\fBCONF_modules_load_file\fR\|(3) with \s-1NULL\s0 filename and application name and the
  354. \&\fB\s-1CONF_MFLAGS_IGNORE_MISSING_FILE\s0\fR, \fB\s-1CONF_MFLAGS_IGNORE_RETURN_CODES\s0\fR and
  355. \&\fB\s-1CONF_MFLAGS_DEFAULT_SECTION\s0\fR flags.
  356. The filename, application name, and flags can be customized by providing a
  357. non-null \fB\s-1OPENSSL_INIT_SETTINGS\s0\fR object.
  358. The object can be allocated via \fB\fBOPENSSL_INIT_new()\fB\fR.
  359. The \fB\fBOPENSSL_INIT_set_config_filename()\fB\fR function can be used to specify a
  360. nondefault filename, which is copied and need not refer to persistent storage.
  361. Similarly, \fBOPENSSL_INIT_set_config_appname()\fR can be used to specify a
  362. nondefault application name.
  363. Finally, OPENSSL_INIT_set_file_flags can be used to specify nondefault flags.
  364. If the \fB\s-1CONF_MFLAGS_IGNORE_RETURN_CODES\s0\fR flag is not included, any errors in
  365. the configuration file will cause an error return from \fBOPENSSL_init_crypto\fR
  366. or indirectly \fBOPENSSL_init_ssl\fR\|(3).
  367. The object can be released with \fBOPENSSL_INIT_free()\fR when done.
  368. If the argument to \fBOPENSSL_INIT_free()\fR is \s-1NULL,\s0 nothing is done.
  369. .SH "NOTES"
  370. .IX Header "NOTES"
  371. Resources local to a thread are deallocated automatically when the thread exits
  372. (e.g. in a pthreads environment, when \fBpthread_exit()\fR is called). On Windows
  373. platforms this is done in response to a \s-1DLL_THREAD_DETACH\s0 message being sent to
  374. the libcrypto32.dll entry point. Some windows functions may cause threads to exit
  375. without sending this message (for example \fBExitProcess()\fR). If the application
  376. uses such functions, then the application must free up OpenSSL resources
  377. directly via a call to \fBOPENSSL_thread_stop()\fR on each thread. Similarly this
  378. message will also not be sent if OpenSSL is linked statically, and therefore
  379. applications using static linking should also call \fBOPENSSL_thread_stop()\fR on each
  380. thread. Additionally if OpenSSL is loaded dynamically via \fBLoadLibrary()\fR and the
  381. threads are not destroyed until after \fBFreeLibrary()\fR is called then each thread
  382. should call \fBOPENSSL_thread_stop()\fR prior to the \fBFreeLibrary()\fR call.
  383. .PP
  384. On Linux/Unix where OpenSSL has been loaded via \fBdlopen()\fR and the application is
  385. multi-threaded and if \fBdlclose()\fR is subsequently called prior to the threads
  386. being destroyed then OpenSSL will not be able to deallocate resources associated
  387. with those threads. The application should either call \fBOPENSSL_thread_stop()\fR on
  388. each thread prior to the \fBdlclose()\fR call, or alternatively the original \fBdlopen()\fR
  389. call should use the \s-1RTLD_NODELETE\s0 flag (where available on the platform).
  390. .SH "RETURN VALUES"
  391. .IX Header "RETURN VALUES"
  392. The functions OPENSSL_init_crypto, \fBOPENSSL_atexit()\fR and
  393. \&\fBOPENSSL_INIT_set_config_appname()\fR return 1 on success or 0 on error.
  394. .SH "SEE ALSO"
  395. .IX Header "SEE ALSO"
  396. \&\fBOPENSSL_init_ssl\fR\|(3)
  397. .SH "HISTORY"
  398. .IX Header "HISTORY"
  399. The \fBOPENSSL_init_crypto()\fR, \fBOPENSSL_cleanup()\fR, \fBOPENSSL_atexit()\fR,
  400. \&\fBOPENSSL_thread_stop()\fR, \fBOPENSSL_INIT_new()\fR, \fBOPENSSL_INIT_set_config_appname()\fR
  401. and \fBOPENSSL_INIT_free()\fR functions were added in OpenSSL 1.1.0.
  402. .SH "COPYRIGHT"
  403. .IX Header "COPYRIGHT"
  404. Copyright 2016\-2024 The OpenSSL Project Authors. All Rights Reserved.
  405. .PP
  406. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  407. this file except in compliance with the License. You can obtain a copy
  408. in the file \s-1LICENSE\s0 in the source distribution or at
  409. <https://www.openssl.org/source/license.html>.