Use default openssl.cnf if config filename set to NULL and
authorDr. Stephen Henson <steve@openssl.org>
Tue, 19 Feb 2002 23:25:18 +0000 (23:25 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Tue, 19 Feb 2002 23:25:18 +0000 (23:25 +0000)
openssl_conf if appname NULL.

CHANGES
apps/apps.c
crypto/conf/conf_mall.c
crypto/conf/conf_mod.c

diff --git a/CHANGES b/CHANGES
index bfb55629206fb0a6cca25b7b20667b186bc09202..10c31f5d844f329c94144cfeff7b8d3476dd05d0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
          *) 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().
index 7864e792e313ddd76ea584c0fb878706a1ac3780..cb04ede33ee51d0f74bf3aabefbea8abd645e359 100644 (file)
@@ -1314,3 +1314,23 @@ ENGINE *setup_engine(BIO *err, const char *engine, int debug)
                }
         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;
+       }
index e7b4bdb65e190232369fe207bc7b51bee5c5d4fb..c1bab7df3ab2fe1e55e062ea1b25cdd1140f5e89 100644 (file)
@@ -83,26 +83,14 @@ static int openssl_configured = 0;
 
 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();
index b922f01ba7093f6d2e46633cf327c762b100d2e3..7e88cfb62506c986e11d1bf75cb79089215bed63 100644 (file)
@@ -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,
                           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))
@@ -183,6 +195,8 @@ int CONF_modules_load_file(const char *filename, const char *appname,
        ret = CONF_modules_load(conf, appname, flags);
 
        err:
+       if (filename == NULL)
+               OPENSSL_free(file);
        NCONF_free(conf);
 
        return ret;