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;
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)
{
BIO *dup_bio_in(void);
BIO *dup_bio_out(void);
BIO *bio_open_default(const char *filename, const char *mode);
-CONF *app_load_config(const char* filename);
+BIO *bio_open_default_quiet(const char *filename, const char *mode);
+CONF *app_load_config(const char *filename);
+CONF *app_load_config_quiet(const char *filename);
+int app_load_modules(const CONF *config);
void unbuffer(FILE *fp);
/* Often used in calls to bio_open_default. */
argc = opt_num_rest();
argv = opt_rest();
+ if (!app_load_modules(NULL))
+ goto end;
+
if (oidfile != NULL) {
- in = bio_open_default(oidfile, "r");
+ in = bio_open_default(oidfile, "r");
if (in == NULL)
goto end;
OBJ_create_objects(in);
BIO_printf(bio_err, "Using configuration from %s\n", configfile);
if ((conf = app_load_config(configfile)) == NULL)
goto end;
+ if (!app_load_modules(conf))
+ goto end;
/* Lets get the config section we are using */
if (section == NULL) {
else if (argc != 0)
goto opthelp;
+ if (!app_load_modules(NULL))
+ goto end;
+
ctx = SSL_CTX_new(meth);
if (ctx == NULL)
goto err;
} else if (!operation)
goto opthelp;
-
if (!app_passwd(passinarg, NULL, &passin, NULL)) {
BIO_printf(bio_err, "Error getting password\n");
goto end;
}
+ if (!app_load_modules(NULL))
+ goto end;
+
if (need_rand) {
app_RAND_load_file(NULL, (inrand != NULL));
if (inrand != NULL)
argc = opt_num_rest();
argv = opt_rest();
+ if (!app_load_modules(NULL))
+ goto end;
+
x = load_crl(infile, informat);
if (x == NULL)
goto end;
argc = opt_num_rest();
argv = opt_rest();
+ if (!app_load_modules(NULL))
+ goto end;
+
if (!nocrl) {
in = bio_open_default(infile, RB(informat));
if (in == NULL)
argc = opt_num_rest();
argv = opt_rest();
+ if (!app_load_modules(NULL))
+ goto end;
+
if (do_verify && !sigfile) {
BIO_printf(bio_err,
"No signature to verify: use the -signature option\n");
argc = opt_num_rest();
argv = opt_rest();
+ if (!app_load_modules(NULL))
+ goto end;
+
if (argv[0] && (!opt_int(argv[0], &num) || num <= 0))
goto end;
goto end;
}
+ if (!app_load_modules(NULL))
+ goto end;
+
BIO_printf(bio_err, "read DSA key\n");
{
EVP_PKEY *pkey;
argc = opt_num_rest();
argv = opt_rest();
+ if (!app_load_modules(NULL))
+ goto end;
+
if (argc == 1) {
if (!opt_int(argv[0], &num))
goto end;
goto end;
}
+ if (!app_load_modules(NULL))
+ goto end;
+
in = bio_open_default(infile, RB(informat));
if (in == NULL)
goto end;
argc = opt_num_rest();
argv = opt_rest();
+ if (!app_load_modules(NULL))
+ goto end;
+
in = bio_open_default(infile, RB(informat));
if (in == NULL)
goto end;
argc = opt_num_rest();
argv = opt_rest();
+ if (!app_load_modules(NULL))
+ goto end;
+
if (cipher && EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) {
BIO_printf(bio_err, "%s: AEAD ciphers not supported\n", prog);
goto end;
}
}
+ if (!app_load_modules(NULL))
+ goto end;
+
for (i = 0; i < sk_OPENSSL_STRING_num(engines); i++) {
const char *id = sk_OPENSSL_STRING_value(engines, i);
if ((e = ENGINE_by_id(id)) != NULL) {
goto end;
}
+ if (!app_load_modules(NULL))
+ goto end;
+
in = bio_open_default(dsaparams, "r");
if (in == NULL)
goto end2;
goto end;
}
+ if (!app_load_modules(NULL))
+ goto end;
+
out = bio_open_default(outfile, "wb");
if (out == NULL)
goto end;
goto end;
}
+ if (!app_load_modules(NULL))
+ goto end;
+
out = bio_open_default(outfile, "w");
if (out == NULL)
goto end;
argc = opt_num_rest();
argv = opt_rest();
+ if (!app_load_modules(NULL))
+ goto end;
+
in = bio_open_default(infile, "r");
if (in == NULL)
goto end;
if (!req && !reqin && !respin && !(port && ridx_filename))
goto opthelp;
+ if (!app_load_modules(NULL))
+ goto end;
+
out = bio_open_default(outfile, "w");
if (out == NULL)
goto end;
setbuf(fp, NULL);
}
-BIO *bio_open_default(const char *filename, const char *mode)
+static BIO *bio_open_default_(const char *filename, const char *mode, int quiet)
{
BIO *ret;
if (filename == NULL || strcmp(filename, "-") == 0) {
ret = *mode == 'r' ? dup_bio_in() : dup_bio_out();
+ if (quiet) {
+ ERR_clear_error();
+ return ret;
+ }
if (ret != NULL)
return ret;
BIO_printf(bio_err,
*mode == 'r' ? "stdin" : "stdout", strerror(errno));
} else {
ret = BIO_new_file(filename, mode);
+ if (quiet) {
+ ERR_clear_error();
+ return ret;
+ }
if (ret != NULL)
return ret;
BIO_printf(bio_err,
ERR_print_errors(bio_err);
return NULL;
}
+BIO *bio_open_default(const char *filename, const char *mode)
+{
+ return bio_open_default_(filename, mode, 0);
+}
+BIO *bio_open_default_quiet(const char *filename, const char *mode)
+{
+ return bio_open_default_(filename, mode, 1);
+}
#if defined( OPENSSL_SYS_VMS)
extern char **copy_argv(int *argc, char **argv);
goto opthelp;
# endif
+ if (!app_load_modules(NULL))
+ goto end;
+
if (infile && in_stdin) {
BIO_printf(bio_err, "%s: Can't combine -in and -stdin\n", prog);
goto end;
mpass = macpass;
}
+ if (!app_load_modules(NULL))
+ goto end;
+
if (export_cert || inrand) {
app_RAND_load_file(NULL, (inrand != NULL));
if (inrand != NULL)
argc = opt_num_rest();
argv = opt_rest();
+ if (!app_load_modules(NULL))
+ goto end;
+
in = bio_open_default(infile, RB(informat));
if (in == NULL)
goto end;
goto end;
}
+ if (!app_load_modules(NULL))
+ goto end;
+
if ((pbe_nid == -1) && !cipher)
pbe_nid = NID_pbeWithMD5AndDES_CBC;
goto end;
}
+ if (!app_load_modules(NULL))
+ goto end;
+
out = bio_open_default(outfile, "wb");
if (out == NULL)
goto end;
argc = opt_num_rest();
argv = opt_rest();
+ if (!app_load_modules(NULL))
+ goto end;
+
in = bio_open_default(infile, "r");
if (in == NULL)
goto end;
if (ctx == NULL)
goto opthelp;
+ if (!app_load_modules(NULL))
+ goto end;
+
if (sigfile && (pkey_op != EVP_PKEY_OP_VERIFY)) {
BIO_printf(bio_err,
"%s: Signature file specified for non verify\n", prog);
argc = opt_num_rest();
argv = opt_rest();
+ if (!app_load_modules(NULL))
+ goto end;
+
if (argc == 0 && !generate) {
BIO_printf(bio_err, "%s: No prime specified\n", prog);
goto end;
if (sscanf(argv[0], "%d", &num) != 1 || num < 0)
goto opthelp;
+ if (!app_load_modules(NULL))
+ goto end;
+
app_RAND_load_file(NULL, (inrand != NULL));
if (inrand != NULL)
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
if (verbose)
BIO_printf(bio_err, "Using configuration from %s\n", template);
req_conf = app_load_config(template);
+ if (!app_load_modules(req_conf))
+ goto end;
+
if (req_conf != NULL) {
p = NCONF_get_string(req_conf, NULL, "oid_file");
if (p == NULL)
goto end;
}
+ if (!app_load_modules(NULL))
+ goto end;
+
if (check && pubin) {
BIO_printf(bio_err, "Only private keys can be checked\n");
goto end;
goto end;
}
+ if (!app_load_modules(NULL))
+ goto end;
+
/* FIXME: seed PRNG only if needed */
app_RAND_load_file(NULL, 0);
argc = opt_num_rest();
argv = opt_rest();
+ if (!app_load_modules(NULL))
+ goto end;
+
if (proxystr) {
if (connectstr == NULL) {
BIO_printf(bio_err, "%s: -proxy requires use of -connect\n", prog);
goto end;
}
+ if (!app_load_modules(NULL))
+ goto end;
+
if (s_key_file == NULL)
s_key_file = s_cert_file;
goto end;
}
+ if (!app_load_modules(NULL))
+ goto end;
+
if (need_rand) {
app_RAND_load_file(NULL, (inrand != NULL));
if (inrand != NULL)
argc = opt_num_rest();
argv = opt_rest();
+ if (!app_load_modules(NULL))
+ goto end;
+
/* Remaining arguments are algorithms. */
for ( ; *argv; argv++) {
if (found(*argv, doit_choices, &i)) {
if ((conf = app_load_config(infile)) == NULL)
goto end;
+ if (!app_load_modules(conf))
+ goto end;
spkstr = NCONF_get_string(conf, spksect, spkac);
conf = app_load_config(configfile);
if (conf == NULL)
goto end;
+ if (!app_load_modules(conf))
+ goto end;
/* Lets get the config section we are using */
if (section == NULL) {
goto end;
}
+ conf = load_config_file(configfile);
+ if (!app_load_modules(conf))
+ goto end;
+
/*
* Check consistency of parameters and execute the appropriate function.
*/
ret = data != NULL && digest != NULL;
if (ret)
goto opthelp;
- /* Load the config file for possible policy OIDs. */
- conf = load_config_file(configfile);
ret = !query_command(data, digest, md, policy, no_nonce, cert,
in, out, text);
break;
case OPT_REPLY:
- conf = load_config_file(configfile);
if (in == NULL) {
ret = !(queryfile != NULL && conf != NULL && !token_in);
if (ret)
argc = opt_num_rest();
argv = opt_rest();
+ if (!app_load_modules(NULL))
+ goto end;
+
if ((store = setup_verify(CAfile, CApath)) == NULL)
goto end;
X509_STORE_set_verify_cb(store, cb);
goto opthelp;
}
+ if (!app_load_modules(NULL))
+ goto end;
+
out = bio_open_default(outfile, "w");
if (out == NULL)
goto end;