5 OSSL_LIB_CTX, OSSL_LIB_CTX_new, OSSL_LIB_CTX_free, OSSL_LIB_CTX_load_config,
6 OSSL_LIB_CTX_get0_global_default, OSSL_LIB_CTX_set0_default
7 - OpenSSL library context
11 #include <openssl/crypto.h>
13 typedef struct ossl_lib_ctx_st OSSL_LIB_CTX;
15 OSSL_LIB_CTX *OSSL_LIB_CTX_new(void);
16 int OSSL_LIB_CTX_load_config(OSSL_LIB_CTX *ctx, const char *config_file);
17 void OSSL_LIB_CTX_free(OSSL_LIB_CTX *ctx);
18 OSSL_LIB_CTX *OSSL_LIB_CTX_get0_global_default(void);
19 OSSL_LIB_CTX *OSSL_LIB_CTX_set0_default(OSSL_LIB_CTX *ctx);
23 B<OSSL_LIB_CTX> is an internal OpenSSL library context type.
24 Applications may allocate their own, but may also use NULL to use
25 a default context with functions that take an B<OSSL_LIB_CTX>
28 When a non default library context is in use care should be taken with
29 multi-threaded applications to properly clean up thread local resources before
30 the OSSL_LIB_CTX is freed.
31 See L<OPENSSL_thread_stop_ex(3)> for more information.
33 OSSL_LIB_CTX_new() creates a new OpenSSL library context.
35 OSSL_LIB_CTX_load_config() loads a configuration file using the given C<ctx>.
36 This can be used to associate a library context with providers that are loaded
39 OSSL_LIB_CTX_free() frees the given I<ctx>, unless it happens to be the
40 default OpenSSL library context.
42 OSSL_LIB_CTX_get0_global_default() returns a concrete (non NULL) reference to
43 the global default library context.
45 OSSL_LIB_CTX_set0_default() sets the default OpenSSL library context to be
46 I<ctx> in the current thread. The previous default library context is
47 returned. Care should be taken by the caller to restore the previous
48 default library context with a subsequent call of this function. If I<ctx> is
49 NULL then no change is made to the default library context, but a pointer to
50 the current library context is still returned. On a successful call of this
51 function the returned value will always be a concrete (non NULL) library
54 Care should be taken when changing the default library context and starting
55 async jobs (see L<ASYNC_start_job(3)>), as the default library context when
56 the job is started will be used throughout the lifetime of an async job, no
57 matter how the calling thread makes further default library context changes
58 in the mean time. This means that the calling thread must not free the
59 library context that was the default at the start of the async job before
60 that job has finished.
64 OSSL_LIB_CTX_new(), OSSL_LIB_CTX_get0_global_default() and
65 OSSL_LIB_CTX_set0_default() return a library context pointer on success, or NULL
68 OSSL_LIB_CTX_free() doesn't return any value.
72 OSSL_LIB_CTX, OSSL_LIB_CTX_new(), OSSL_LIB_CTX_load_config(),
73 OSSL_LIB_CTX_free(), OSSL_LIB_CTX_get0_global_default() and
74 OSSL_LIB_CTX_set0_default() were added in OpenSSL 3.0.
78 Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
80 Licensed under the Apache License 2.0 (the "License"). You may not use
81 this file except in compliance with the License. You can obtain a copy
82 in the file LICENSE in the source distribution or at
83 L<https://www.openssl.org/source/license.html>.