Skip to content

Commit

Permalink
no_autoload: make the no-autoload-config option work again.
Browse files Browse the repository at this point in the history
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from #21621)
  • Loading branch information
paulidale committed Aug 4, 2023
1 parent 9a255aa commit cb8e641
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions crypto/asn1/a_strnid.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
int idx;
ASN1_STRING_TABLE fnd;

#ifndef OPENSSL_NO_AUTOLOAD_CONFIG
/* "stable" can be impacted by config, so load the config file first */
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL);
#endif

fnd.nid = nid;
if (stable != NULL) {
Expand Down
2 changes: 2 additions & 0 deletions crypto/engine/eng_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,10 @@ ENGINE *ossl_engine_table_select(ENGINE_TABLE **table, int nid,
ENGINE_PILE tmplate, *fnd = NULL;
int initres, loop = 0;

#ifndef OPENSSL_NO_AUTOLOAD_CONFIG
/* Load the config before trying to check if engines are available */
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL);
#endif

if (!(*table)) {
OSSL_TRACE3(ENGINE_TABLE,
Expand Down
2 changes: 2 additions & 0 deletions crypto/objects/obj_dat.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ DEFINE_RUN_ONCE_STATIC(obj_lock_initialise)

static ossl_inline int ossl_init_added_lock(void)
{
#ifndef OPENSSL_NO_AUTOLOAD_CONFIG
/* Make sure we've loaded config before checking for any "added" objects */
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL);
#endif
return RUN_ONCE(&ossl_obj_lock_init, obj_lock_initialise);
}

Expand Down
6 changes: 3 additions & 3 deletions crypto/property/property.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ void *ossl_ctx_global_properties_new(OSSL_LIB_CTX *ctx)
}

OSSL_PROPERTY_LIST **ossl_ctx_global_properties(OSSL_LIB_CTX *libctx,
int loadconfig)
ossl_unused int loadconfig)
{
OSSL_GLOBAL_PROPERTIES *globp;

#ifndef FIPS_MODULE
#if !defined(FIPS_MODULE) && !defined(OPENSSL_NO_AUTOLOAD_CONFIG)
if (loadconfig && !OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL))
return NULL;
#endif
Expand Down Expand Up @@ -505,7 +505,7 @@ int ossl_method_store_fetch(OSSL_METHOD_STORE *store,
if (nid <= 0 || method == NULL || store == NULL)
return 0;

#ifndef FIPS_MODULE
#if !defined(FIPS_MODULE) && !defined(OPENSSL_NO_AUTOLOAD_CONFIG)
if (ossl_lib_ctx_is_default(store->ctx)
&& !OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL))
return 0;
Expand Down
6 changes: 3 additions & 3 deletions crypto/provider_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ int ossl_provider_info_add_to_store(OSSL_LIB_CTX *libctx,
}

OSSL_PROVIDER *ossl_provider_find(OSSL_LIB_CTX *libctx, const char *name,
int noconfig)
ossl_unused int noconfig)
{
struct provider_store_st *store = NULL;
OSSL_PROVIDER *prov = NULL;
Expand All @@ -405,7 +405,7 @@ OSSL_PROVIDER *ossl_provider_find(OSSL_LIB_CTX *libctx, const char *name,
OSSL_PROVIDER tmpl = { 0, };
int i;

#ifndef FIPS_MODULE
#if !defined(FIPS_MODULE) && !defined(OPENSSL_NO_AUTOLOAD_CONFIG)
/*
* Make sure any providers are loaded from config before we try to find
* them.
Expand Down Expand Up @@ -1387,7 +1387,7 @@ int ossl_provider_doall_activated(OSSL_LIB_CTX *ctx,
struct provider_store_st *store = get_provider_store(ctx);
STACK_OF(OSSL_PROVIDER) *provs = NULL;

#ifndef FIPS_MODULE
#if !defined(FIPS_MODULE) && !defined(OPENSSL_NO_AUTOLOAD_CONFIG)
/*
* Make sure any providers are loaded from config before we try to use
* them.
Expand Down

0 comments on commit cb8e641

Please sign in to comment.