diff options
author | Richard Levitte <levitte@openssl.org> | 2015-05-29 08:07:10 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2015-05-29 12:41:50 +0200 |
commit | 296f54ee211edbf8d21479091b4c20a9ee7698ad (patch) | |
tree | 4f746de806c85723368d65c4ab36d8e34974b214 /apps/apps.c | |
parent | 21425195009e4daf6971453f8a0be08375ae9eec (diff) |
Restore module loading
The module loading feature got broken a while ago, so restore it, but
have it a bit more explicit this time around.
Reviewed-by: Stephen Henson <steve@openssl.org>
Diffstat (limited to 'apps/apps.c')
-rw-r--r-- | apps/apps.c | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/apps/apps.c b/apps/apps.c index 74646afae6..60f71c3b8b 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -496,20 +496,14 @@ static char *app_get_pass(char *arg, int keepbio) return BUF_strdup(tpass); } -CONF *app_load_config(const char *filename) +static CONF *app_load_config_(BIO *in, const char *filename) { long errorline = -1; CONF *conf; int i; - BIO *in; - - in = bio_open_default(filename, "r"); - if (in == NULL) - return NULL; conf = NCONF_new(NULL); i = NCONF_load_bio(conf, in, &errorline); - BIO_free(in); if (i > 0) return conf; @@ -522,6 +516,51 @@ CONF *app_load_config(const char *filename) NCONF_free(conf); return NULL; } +CONF *app_load_config(const char *filename) +{ + BIO *in; + CONF *conf; + + in = bio_open_default(filename, "r"); + if (in == NULL) + return NULL; + + conf = app_load_config_(in, filename); + BIO_free(in); + return conf; +} +CONF *app_load_config_quiet(const char *filename) +{ + BIO *in; + CONF *conf; + + in = bio_open_default_quiet(filename, "r"); + if (in == NULL) + return NULL; + + conf = app_load_config_(in, filename); + BIO_free(in); + return conf; +} + +int app_load_modules(const CONF *config) +{ + CONF *to_free = NULL; + + if (config == NULL) + config = to_free = app_load_config_quiet(default_config_file); + if (config == NULL) + return 1; + + if (CONF_modules_load(config, NULL, 0) <= 0) { + BIO_printf(bio_err, "Error configuring OpenSSL modules\n"); + ERR_print_errors(bio_err); + NCONF_free(to_free); + return 0; + } + NCONF_free(to_free); + return 1; +} int add_oid_section(CONF *conf) { |