mirror of https://github.com/openssl/openssl
apps/cmp.c: refactor to fix some coding style nits and more convenient source-level debugging
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com> (Merged from https://github.com/openssl/openssl/pull/21660)
This commit is contained in:
parent
5003abae02
commit
a143e4e3c9
35
apps/cmp.c
35
apps/cmp.c
|
@ -1130,7 +1130,7 @@ static OSSL_CMP_SRV_CTX *setup_srv_ctx(ENGINE *engine)
|
||||||
if (!setup_cert(srv_ctx, opt_ref_cert, opt_otherpass,
|
if (!setup_cert(srv_ctx, opt_ref_cert, opt_otherpass,
|
||||||
"reference cert to be expected by the mock server",
|
"reference cert to be expected by the mock server",
|
||||||
(add_X509_fn_t)ossl_cmp_mock_srv_set1_refCert))
|
(add_X509_fn_t)ossl_cmp_mock_srv_set1_refCert))
|
||||||
goto err;
|
goto err;
|
||||||
if (opt_rsp_cert == NULL) {
|
if (opt_rsp_cert == NULL) {
|
||||||
CMP_warn("no -rsp_cert given for mock server");
|
CMP_warn("no -rsp_cert given for mock server");
|
||||||
} else {
|
} else {
|
||||||
|
@ -1598,7 +1598,8 @@ static int setup_request_ctx(OSSL_CMP_CTX *ctx, ENGINE *engine)
|
||||||
if (!set_name(opt_subject, OSSL_CMP_CTX_set1_subjectName, ctx, "subject"))
|
if (!set_name(opt_subject, OSSL_CMP_CTX_set1_subjectName, ctx, "subject"))
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
CMP_warn1("-subject %s since sender is taken from -ref or -cert", msg);
|
CMP_warn1("-subject %s since sender is taken from -ref or -cert",
|
||||||
|
msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (opt_issuer != NULL && opt_cmd != CMP_RR)
|
if (opt_issuer != NULL && opt_cmd != CMP_RR)
|
||||||
|
@ -3105,25 +3106,17 @@ static int do_genm(OSSL_CMP_CTX *ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmp_main(int argc, char **argv)
|
static int handle_opts_upfront(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *configfile = NULL;
|
|
||||||
int i;
|
int i;
|
||||||
X509 *newcert = NULL;
|
|
||||||
ENGINE *engine = NULL;
|
|
||||||
OSSL_CMP_CTX *srv_cmp_ctx = NULL;
|
|
||||||
int ret = 0; /* default: failure */
|
|
||||||
|
|
||||||
prog = opt_appname(argv[0]);
|
prog = opt_appname(argv[0]);
|
||||||
if (argc <= 1) {
|
if (argc <= 1) {
|
||||||
opt_help(cmp_options);
|
opt_help(cmp_options);
|
||||||
goto err;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* handle -config, -section, and -verbosity to take effect for other opts */
|
||||||
* handle options -config, -section, and -verbosity upfront
|
|
||||||
* to take effect for other options
|
|
||||||
*/
|
|
||||||
for (i = 1; i < argc - 1; i++) {
|
for (i = 1; i < argc - 1; i++) {
|
||||||
if (*argv[i] == '-') {
|
if (*argv[i] == '-') {
|
||||||
if (!strcmp(argv[i] + 1, cmp_options[OPT_CONFIG - OPT_HELP].name))
|
if (!strcmp(argv[i] + 1, cmp_options[OPT_CONFIG - OPT_HELP].name))
|
||||||
|
@ -3134,11 +3127,25 @@ int cmp_main(int argc, char **argv)
|
||||||
else if (strcmp(argv[i] + 1,
|
else if (strcmp(argv[i] + 1,
|
||||||
cmp_options[OPT_VERBOSITY - OPT_HELP].name) == 0
|
cmp_options[OPT_VERBOSITY - OPT_HELP].name) == 0
|
||||||
&& !set_verbosity(atoi(argv[++i])))
|
&& !set_verbosity(atoi(argv[++i])))
|
||||||
goto err;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (opt_section[0] == '\0') /* empty string */
|
if (opt_section[0] == '\0') /* empty string */
|
||||||
opt_section = DEFAULT_SECTION;
|
opt_section = DEFAULT_SECTION;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cmp_main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
char *configfile = NULL;
|
||||||
|
int i;
|
||||||
|
X509 *newcert = NULL;
|
||||||
|
ENGINE *engine = NULL;
|
||||||
|
OSSL_CMP_CTX *srv_cmp_ctx = NULL;
|
||||||
|
int ret = 0; /* default: failure */
|
||||||
|
|
||||||
|
if (!handle_opts_upfront(argc, argv))
|
||||||
|
goto err;
|
||||||
|
|
||||||
vpm = X509_VERIFY_PARAM_new();
|
vpm = X509_VERIFY_PARAM_new();
|
||||||
if (vpm == NULL) {
|
if (vpm == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue