{"outform", OPT_OUTFORM, 'F', "Output format - DER or PEM"},
{"in", OPT_IN, '<', "Input file"},
{"out", OPT_OUT, '>', "Output file"},
- {"keygen_engine", OPT_KEYGEN_ENGINE, 's'},
{"key", OPT_KEY, '<', "Use the private key contained in file"},
{"keyform", OPT_KEYFORM, 'F', "Key file format"},
{"pubkey", OPT_PUBKEY, '-', "Output public key"},
"Request extension section (override value in config file)"},
#ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
+ {"keygen_engine", OPT_KEYGEN_ENGINE, 's'},
#endif
{"", OPT_MD, '-', "Any supported digest"},
{NULL}
X509_REQ *req = NULL;
const EVP_CIPHER *cipher = NULL;
const EVP_MD *md_alg = NULL, *digest = NULL;
- char *engine = NULL, *extensions = NULL, *infile = NULL;
+ char *extensions = NULL, *infile = NULL;
char *outfile = NULL, *keyfile = NULL, *inrand = NULL;
char *keyalgstr = NULL, *p, *prog, *passargin = NULL, *passargout = NULL;
char *passin = NULL, *passout = NULL, *req_exts = NULL, *subj = NULL;
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &outformat))
goto opthelp;
break;
-#ifndef OPENSSL_NO_ENGINE
case OPT_ENGINE:
- engine = optarg;
+ (void)setup_engine(opt_arg(), 0);
break;
case OPT_KEYGEN_ENGINE:
+#ifndef OPENSSL_NO_ENGINE
gen_eng = ENGINE_by_id(opt_arg());
if (gen_eng == NULL) {
BIO_printf(bio_err, "Can't find keygen engine %s\n", *argv);
- goto end;
+ goto opthelp;
}
- break;
#endif
+ break;
case OPT_KEY:
keyfile = opt_arg();
break;
p = NCONF_get_string(req_conf, SECTION, UTF8_IN);
if (!p)
ERR_clear_error();
- else if (!strcmp(p, "yes"))
+ else if (strcmp(p, "yes") == 0)
chtype = MBSTRING_UTF8;
}
goto end;
}
}
-#ifndef OPENSSL_NO_ENGINE
- e = setup_engine(engine, 0);
-#endif
if (keyfile != NULL) {
pkey = load_key(keyfile, keyform, 0, passin, e, "Private Key");
}
goto end;
}
+ BIO_free(out);
BIO_printf(bio_err, "-----\n");
}
if (ret) {
ERR_print_errors(bio_err);
}
- if ((req_conf != NULL) && (req_conf != config))
+ if (req_conf != config)
NCONF_free(req_conf);
BIO_free(in);
BIO_free_all(out);
EVP_PKEY_free(pkey);
EVP_PKEY_CTX_free(genctx);
- if (pkeyopts)
- sk_OPENSSL_STRING_free(pkeyopts);
- if (sigopts)
- sk_OPENSSL_STRING_free(sigopts);
+ sk_OPENSSL_STRING_free(pkeyopts);
+ sk_OPENSSL_STRING_free(sigopts);
#ifndef OPENSSL_NO_ENGINE
- if (gen_eng)
- ENGINE_free(gen_eng);
+ ENGINE_free(gen_eng);
#endif
- if (keyalgstr)
- OPENSSL_free(keyalgstr);
+ OPENSSL_free(keyalgstr);
X509_REQ_free(req);
X509_free(x509ss);
ASN1_INTEGER_free(serial);
- if (passargin && passin)
- OPENSSL_free(passin);
- if (passargout && passout)
- OPENSSL_free(passout);
+ OPENSSL_free(passin);
+ OPENSSL_free(passout);
OBJ_cleanup();
return (ret);
}
tmp = NCONF_get_string(req_conf, SECTION, PROMPT);
if (tmp == NULL)
ERR_clear_error();
- if ((tmp != NULL) && !strcmp(tmp, "no"))
+ if ((tmp != NULL) && strcmp(tmp, "no") == 0)
no_prompt = 1;
dn_sect = NCONF_get_string(req_conf, SECTION, DISTINGUISHED_NAME);
{
X509_NAME *n;
- if (!(n = parse_name(subject, chtype, multirdn)))
+ if ((n = parse_name(subject, chtype, multirdn)) == NULL)
return 0;
if (!X509_REQ_set_subject_name(req, n)) {
*pkey_type = EVP_PKEY_RSA;
keylen = atol(gstr);
*pkeylen = keylen;
- } else if (!strncmp(gstr, "param:", 6))
+ } else if (strncmp(gstr, "param:", 6) == 0)
paramfile = gstr + 6;
else {
const char *p = strchr(gstr, ':');