OSSL_LIB_CTX.pod 3.1 KB

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