X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=apps%2Fca.c;h=437a375427ef6e86f79beb2acdebc409c2bbecab;hp=58f1243cdf650c6f4f2f9c9317225d92456a3659;hb=cc01d21756cc9c79231ef21039782c5fe42008a2;hpb=f097f81c891bb1f479426d8ac9c9541390334983;ds=sidebyside diff --git a/apps/ca.c b/apps/ca.c index 58f1243cdf..437a375427 100644 --- a/apps/ca.c +++ b/apps/ca.c @@ -99,7 +99,6 @@ #define BSIZE 256 #define BASE_SECTION "ca" -#define CONFIG_FILE "openssl.cnf" #define ENV_DEFAULT_CA "default_ca" @@ -285,7 +284,8 @@ int ca_main(int argc, char **argv) STACK_OF(X509) *cert_sk = NULL; X509_CRL *crl = NULL; const EVP_MD *dgst = NULL; - char *configfile = NULL, *md = NULL, *policy = NULL, *keyfile = NULL; + char *configfile = default_config_file; + char *md = NULL, *policy = NULL, *keyfile = NULL; char *certfile = NULL, *crl_ext = NULL, *crlnumberfile = NULL; char *infile = NULL, *spkac_file = NULL, *ss_cert_file = NULL; char *extensions = NULL, *extfile = NULL, *key = NULL, *passinarg = NULL; @@ -301,7 +301,7 @@ int ca_main(int argc, char **argv) int keyformat = FORMAT_PEM, multirdn = 0, notext = 0, output_der = 0; int ret = 1, email_dn = 1, req = 0, verbose = 0, gencrl = 0, dorevoke = 0; int i, j, rev_type = REV_NONE, selfsign = 0; - long crldays = 0, crlhours = 0, crlsec = 0, errorline = -1, days = 0; + long crldays = 0, crlhours = 0, crlsec = 0, days = 0; unsigned long chtype = MBSTRING_ASC, nameopt = 0, certopt = 0; X509 *x509 = NULL, *x509p = NULL, *x = NULL; X509_REVOKED *r = NULL; @@ -482,40 +482,9 @@ end_of_options: argc = opt_num_rest(); argv = opt_rest(); - tofree = NULL; - if (configfile == NULL) - configfile = getenv("OPENSSL_CONF"); - if (configfile == NULL) - configfile = getenv("SSLEAY_CONF"); - if (configfile == NULL) { - const char *s = X509_get_default_cert_area(); - size_t len; - - len = strlen(s) + 1 + sizeof(CONFIG_FILE); - tofree = app_malloc(len, "config filename"); -#ifdef OPENSSL_SYS_VMS - strcpy(tofree, s); -#else - BUF_strlcpy(tofree, s, len); - BUF_strlcat(tofree, "/", len); -#endif - BUF_strlcat(tofree, CONFIG_FILE, len); - configfile = tofree; - } - BIO_printf(bio_err, "Using configuration from %s\n", configfile); - conf = NCONF_new(NULL); - if (NCONF_load(conf, configfile, &errorline) <= 0) { - if (errorline <= 0) - BIO_printf(bio_err, "error loading the config file '%s'\n", - configfile); - else - BIO_printf(bio_err, "error on line %ld of config file '%s'\n", - errorline, configfile); + if ((conf = app_load_config(configfile)) == NULL) goto end; - } - OPENSSL_free(tofree); - tofree = NULL; /* Lets get the config section we are using */ if (section == NULL) { @@ -800,18 +769,10 @@ end_of_options: } } - /*****************************************************************/ + /*****************************************************************/ /* Read extensions config file */ if (extfile) { - extconf = NCONF_new(NULL); - if (NCONF_load(extconf, extfile, &errorline) <= 0) { - if (errorline <= 0) - BIO_printf(bio_err, "ERROR: loading the config file '%s'\n", - extfile); - else - BIO_printf(bio_err, - "ERROR: on line %ld of config file '%s'\n", - errorline, extfile); + if ((extconf = app_load_config(extfile)) == NULL) { ret = 1; goto end; }