openssl_conf if appname NULL.
*) applies to 0.9.6a/0.9.6b/0.9.6c and 0.9.7
+) 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
config section name. Add a new flag to tolerate a missing config file
and move code to CONF_modules_load_file().
}
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;
+ }
void OPENSSL_config(const char *config_name)
{
- int err_exit = 0;
- char *file;
if (openssl_configured)
return;
OPENSSL_load_builtin_modules();
- file = CONF_get1_default_config_file();
- if (!file)
- return;
- if (config_name == NULL)
- config_name = "openssl_conf";
-
ERR_clear_error();
- if (CONF_modules_load_file(file, config_name,
- CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0)
- err_exit = 1;
-
- OPENSSL_free(file);
- if (err_exit)
+ if (CONF_modules_load_file(NULL, NULL,
+ CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0)
{
BIO *bio_err;
ERR_load_crypto_strings();
int CONF_modules_load_file(const char *filename, const char *appname,
unsigned long flags)
{
+ char *file;
CONF *conf = NULL;
int ret = 0;
conf = NCONF_new(NULL);
if (!conf)
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) &&
(ERR_GET_REASON(ERR_peek_last_error()) == CONF_R_NO_SUCH_FILE))
ret = CONF_modules_load(conf, appname, flags);
err:
+ if (filename == NULL)
+ OPENSSL_free(file);
NCONF_free(conf);
return ret;