# include <openssl/dsa.h>
#endif
-#define SECTION "req"
#define BITS "default_bits"
#define KEYFILE "default_keyfile"
static EVP_PKEY_CTX *set_keygen_ctx(const char *gstr,
int *pkey_type, long *pkeylen,
char **palgnam, ENGINE *keygen_engine);
+
+static const char *section = "req";
static CONF *req_conf = NULL;
static CONF *addext_conf = NULL;
static int batch = 0;
OPT_NAMEOPT, OPT_REQOPT, OPT_SUBJ, OPT_SUBJECT, OPT_TEXT, OPT_X509,
OPT_MULTIVALUE_RDN, OPT_DAYS, OPT_SET_SERIAL, OPT_ADDEXT, OPT_EXTENSIONS,
OPT_REQEXTS, OPT_PRECERT, OPT_MD, OPT_SM2ID, OPT_SM2HEXID,
+ OPT_SECTION,
OPT_R_ENUM, OPT_PROV_ENUM
} OPTION_CHOICE;
OPT_SECTION("Certificate"),
{"new", OPT_NEW, '-', "New request"},
{"config", OPT_CONFIG, '<', "Request template file"},
+ {"section", OPT_SECTION, 's', "Config section to use (default \"req\")"},
{"utf8", OPT_UTF8, '-', "Input characters are UTF8 (default ASCII)"},
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
{"reqopt", OPT_REQOPT, 's', "Various request text options"},
case OPT_CONFIG:
template = opt_arg();
break;
+ case OPT_SECTION:
+ section = opt_arg();
+ break;
case OPT_KEYFORM:
if (!opt_format(opt_arg(), OPT_FMT_ANY, &keyform))
goto opthelp;
goto end;
if (md_alg == NULL) {
- p = NCONF_get_string(req_conf, SECTION, "default_md");
+ p = NCONF_get_string(req_conf, section, "default_md");
if (p == NULL) {
ERR_clear_error();
} else {
}
if (extensions == NULL) {
- extensions = NCONF_get_string(req_conf, SECTION, V3_EXTENSIONS);
+ extensions = NCONF_get_string(req_conf, section, V3_EXTENSIONS);
if (extensions == NULL)
ERR_clear_error();
}
if (passin == NULL) {
passin = nofree_passin =
- NCONF_get_string(req_conf, SECTION, "input_password");
+ NCONF_get_string(req_conf, section, "input_password");
if (passin == NULL)
ERR_clear_error();
}
if (passout == NULL) {
passout = nofree_passout =
- NCONF_get_string(req_conf, SECTION, "output_password");
+ NCONF_get_string(req_conf, section, "output_password");
if (passout == NULL)
ERR_clear_error();
}
- p = NCONF_get_string(req_conf, SECTION, STRING_MASK);
+ p = NCONF_get_string(req_conf, section, STRING_MASK);
if (p == NULL)
ERR_clear_error();
}
if (chtype != MBSTRING_UTF8) {
- p = NCONF_get_string(req_conf, SECTION, UTF8_IN);
+ p = NCONF_get_string(req_conf, section, UTF8_IN);
if (p == NULL)
ERR_clear_error();
else if (strcmp(p, "yes") == 0)
}
if (req_exts == NULL) {
- req_exts = NCONF_get_string(req_conf, SECTION, REQ_EXTENSIONS);
+ req_exts = NCONF_get_string(req_conf, section, REQ_EXTENSIONS);
if (req_exts == NULL)
ERR_clear_error();
}
/* load_key() has already printed an appropriate message */
goto end;
} else {
- app_RAND_load_conf(req_conf, SECTION);
+ app_RAND_load_conf(req_conf, section);
}
}
if (newreq && (pkey == NULL)) {
- app_RAND_load_conf(req_conf, SECTION);
+ app_RAND_load_conf(req_conf, section);
- if (!NCONF_get_number(req_conf, SECTION, BITS, &newkey)) {
+ if (!NCONF_get_number(req_conf, section, BITS, &newkey)) {
newkey = DEFAULT_KEY_LENGTH;
}
genctx = NULL;
if (keyout == NULL) {
- keyout = NCONF_get_string(req_conf, SECTION, KEYFILE);
+ keyout = NCONF_get_string(req_conf, section, KEYFILE);
if (keyout == NULL)
ERR_clear_error();
}
if (out == NULL)
goto end;
- p = NCONF_get_string(req_conf, SECTION, "encrypt_rsa_key");
+ p = NCONF_get_string(req_conf, section, "encrypt_rsa_key");
if (p == NULL) {
ERR_clear_error();
- p = NCONF_get_string(req_conf, SECTION, "encrypt_key");
+ p = NCONF_get_string(req_conf, section, "encrypt_key");
if (p == NULL)
ERR_clear_error();
}
STACK_OF(CONF_VALUE) *dn_sk, *attr_sk = NULL;
char *tmp, *dn_sect, *attr_sect;
- tmp = NCONF_get_string(req_conf, SECTION, PROMPT);
+ tmp = NCONF_get_string(req_conf, section, PROMPT);
if (tmp == NULL)
ERR_clear_error();
if ((tmp != NULL) && strcmp(tmp, "no") == 0)
no_prompt = 1;
- dn_sect = NCONF_get_string(req_conf, SECTION, DISTINGUISHED_NAME);
+ dn_sect = NCONF_get_string(req_conf, section, DISTINGUISHED_NAME);
if (dn_sect == NULL) {
BIO_printf(bio_err, "unable to find '%s' in config\n",
DISTINGUISHED_NAME);
goto err;
}
- attr_sect = NCONF_get_string(req_conf, SECTION, ATTRIBUTES);
+ attr_sect = NCONF_get_string(req_conf, section, ATTRIBUTES);
if (attr_sect == NULL) {
ERR_clear_error();
attr_sk = NULL;