Centralise loading default apps config file

Loading the config file after processing command line options can
cause problems, e.g. where an engine provides new ciphers/digests
these are not then recoginised on the command line. Move the
default config file loading to before the command line option
processing. Whilst we're doing this we might as well centralise
this instead of doing it individually for each application. Finally
if we do it before the OpenSSL_add_ssl_algorithms() call then
ciphersuites provided by an engine (e.g. GOST) can be available to
the apps.

RT#4085
RT#4086

Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
Matt Caswell
2015-10-12 12:40:15 +01:00
parent d175e8a6c2
commit a0a82324f9
38 changed files with 19 additions and 114 deletions

View File

@@ -166,7 +166,7 @@ BIO *bio_in = NULL;
BIO *bio_out = NULL;
BIO *bio_err = NULL;
static void apps_startup()
static int apps_startup()
{
#ifdef SIGPIPE
signal(SIGPIPE, SIG_IGN);
@@ -174,6 +174,13 @@ static void apps_startup()
CRYPTO_malloc_init();
ERR_load_crypto_strings();
ERR_load_SSL_strings();
if (!app_load_modules(NULL)) {
ERR_print_errors(bio_err);
BIO_printf(bio_err, "Error loading default configuration\n");
return 0;
}
OpenSSL_add_all_algorithms();
OpenSSL_add_ssl_algorithms();
OPENSSL_load_builtin_modules();
@@ -182,6 +189,7 @@ static void apps_startup()
#ifndef OPENSSL_NO_ENGINE
ENGINE_load_builtin_engines();
#endif
return 1;
}
static void apps_shutdown()
@@ -328,7 +336,9 @@ int main(int argc, char *argv[])
#endif
}
apps_startup();
if (!apps_startup())
goto end;
prog = prog_init();
pname = opt_progname(argv[0]);