Use default openssl.cnf if config filename set to NULL and
openssl_conf if appname NULL.
This commit is contained in:
parent
54d11e6057
commit
9c75b2d931
4
CHANGES
4
CHANGES
@ -13,6 +13,10 @@
|
|||||||
*) applies to 0.9.6a/0.9.6b/0.9.6c and 0.9.7
|
*) applies to 0.9.6a/0.9.6b/0.9.6c and 0.9.7
|
||||||
+) applies to 0.9.7 only
|
+) applies to 0.9.7 only
|
||||||
|
|
||||||
|
+) Move default behaviour to CONF_modules_load_file(). Is appname is NULL
|
||||||
|
use "openssl_conf" if filename is NULL use default openssl config file.
|
||||||
|
[Steve Henson]
|
||||||
|
|
||||||
+) Add an argument to OPENSSL_config() to allow the use of an alternative
|
+) Add an argument to OPENSSL_config() to allow the use of an alternative
|
||||||
config section name. Add a new flag to tolerate a missing config file
|
config section name. Add a new flag to tolerate a missing config file
|
||||||
and move code to CONF_modules_load_file().
|
and move code to CONF_modules_load_file().
|
||||||
|
20
apps/apps.c
20
apps/apps.c
@ -1314,3 +1314,23 @@ ENGINE *setup_engine(BIO *err, const char *engine, int debug)
|
|||||||
}
|
}
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int load_config(char *filename, BIO *err)
|
||||||
|
{
|
||||||
|
unsigned long flags;
|
||||||
|
if (filename)
|
||||||
|
flags = 0;
|
||||||
|
else
|
||||||
|
flags = CONF_MFLAGS_IGNORE_MISSING_FILE;
|
||||||
|
|
||||||
|
if (CONF_modules_load_file(filename, NULL, flags) <= 0)
|
||||||
|
{
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
BIO_printf(err, "Error loading config file\n");
|
||||||
|
ERR_print_errors(err);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
@ -83,26 +83,14 @@ static int openssl_configured = 0;
|
|||||||
|
|
||||||
void OPENSSL_config(const char *config_name)
|
void OPENSSL_config(const char *config_name)
|
||||||
{
|
{
|
||||||
int err_exit = 0;
|
|
||||||
char *file;
|
|
||||||
if (openssl_configured)
|
if (openssl_configured)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
OPENSSL_load_builtin_modules();
|
OPENSSL_load_builtin_modules();
|
||||||
|
|
||||||
file = CONF_get1_default_config_file();
|
|
||||||
if (!file)
|
|
||||||
return;
|
|
||||||
if (config_name == NULL)
|
|
||||||
config_name = "openssl_conf";
|
|
||||||
|
|
||||||
ERR_clear_error();
|
ERR_clear_error();
|
||||||
if (CONF_modules_load_file(file, config_name,
|
if (CONF_modules_load_file(NULL, NULL,
|
||||||
CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0)
|
CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0)
|
||||||
err_exit = 1;
|
|
||||||
|
|
||||||
OPENSSL_free(file);
|
|
||||||
if (err_exit)
|
|
||||||
{
|
{
|
||||||
BIO *bio_err;
|
BIO *bio_err;
|
||||||
ERR_load_crypto_strings();
|
ERR_load_crypto_strings();
|
||||||
|
@ -163,13 +163,25 @@ int CONF_modules_load(const CONF *cnf, const char *appname,
|
|||||||
int CONF_modules_load_file(const char *filename, const char *appname,
|
int CONF_modules_load_file(const char *filename, const char *appname,
|
||||||
unsigned long flags)
|
unsigned long flags)
|
||||||
{
|
{
|
||||||
|
char *file;
|
||||||
CONF *conf = NULL;
|
CONF *conf = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
conf = NCONF_new(NULL);
|
conf = NCONF_new(NULL);
|
||||||
if (!conf)
|
if (!conf)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (NCONF_load(conf, filename, NULL) <= 0)
|
if (filename == NULL)
|
||||||
|
{
|
||||||
|
file = CONF_get1_default_config_file();
|
||||||
|
if (!file)
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
file = (char *)filename;
|
||||||
|
if (appname == NULL)
|
||||||
|
appname = "openssl_conf";
|
||||||
|
|
||||||
|
if (NCONF_load(conf, file, NULL) <= 0)
|
||||||
{
|
{
|
||||||
if ((flags & CONF_MFLAGS_IGNORE_MISSING_FILE) &&
|
if ((flags & CONF_MFLAGS_IGNORE_MISSING_FILE) &&
|
||||||
(ERR_GET_REASON(ERR_peek_last_error()) == CONF_R_NO_SUCH_FILE))
|
(ERR_GET_REASON(ERR_peek_last_error()) == CONF_R_NO_SUCH_FILE))
|
||||||
@ -183,6 +195,8 @@ int CONF_modules_load_file(const char *filename, const char *appname,
|
|||||||
ret = CONF_modules_load(conf, appname, flags);
|
ret = CONF_modules_load(conf, appname, flags);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
if (filename == NULL)
|
||||||
|
OPENSSL_free(file);
|
||||||
NCONF_free(conf);
|
NCONF_free(conf);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user