mirror of https://github.com/openssl/openssl
CMS print should support string conversion
Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12206)
This commit is contained in:
parent
49a36a528a
commit
6ec351f449
23
apps/cms.c
23
apps/cms.c
|
@ -82,7 +82,7 @@ typedef enum OPTION_choice {
|
|||
OPT_NOINDEF, OPT_CRLFEOL, OPT_NOOUT, OPT_RR_PRINT,
|
||||
OPT_RR_ALL, OPT_RR_FIRST, OPT_RCTFORM, OPT_CERTFILE, OPT_CAFILE,
|
||||
OPT_CAPATH, OPT_CASTORE, OPT_NOCAPATH, OPT_NOCAFILE, OPT_NOCASTORE,
|
||||
OPT_CONTENT, OPT_PRINT,
|
||||
OPT_CONTENT, OPT_PRINT, OPT_NAMEOPT,
|
||||
OPT_SECRETKEY, OPT_SECRETKEYID, OPT_PWRI_PASSWORD, OPT_ECONTENT_TYPE,
|
||||
OPT_PASSIN, OPT_TO, OPT_FROM, OPT_SUBJECT, OPT_SIGNER, OPT_RECIP,
|
||||
OPT_CERTSOUT, OPT_MD, OPT_INKEY, OPT_KEYFORM, OPT_KEYOPT, OPT_RR_FROM,
|
||||
|
@ -184,6 +184,8 @@ const OPTIONS cms_options[] = {
|
|||
"Supply or override content for detached signature"},
|
||||
{"print", OPT_PRINT, '-',
|
||||
"For the -cmsout operation print out all fields of the CMS structure"},
|
||||
{"nameopt", OPT_NAMEOPT, 's',
|
||||
"For the -print option specifies various strings printing options"},
|
||||
{"certsout", OPT_CERTSOUT, '>', "Certificate output file"},
|
||||
|
||||
OPT_SECTION("Keying"),
|
||||
|
@ -466,6 +468,10 @@ int cms_main(int argc, char **argv)
|
|||
case OPT_PRINT:
|
||||
noout = print = 1;
|
||||
break;
|
||||
case OPT_NAMEOPT:
|
||||
if (!set_nameopt(opt_arg()))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_SECRETKEY:
|
||||
if (secret_key != NULL) {
|
||||
BIO_printf(bio_err, "Invalid key (supplied twice) %s\n",
|
||||
|
@ -1152,8 +1158,19 @@ int cms_main(int argc, char **argv)
|
|||
}
|
||||
} else {
|
||||
if (noout) {
|
||||
if (print)
|
||||
CMS_ContentInfo_print_ctx(out, cms, 0, NULL);
|
||||
if (print) {
|
||||
ASN1_PCTX *pctx = NULL;
|
||||
if (get_nameopt() != XN_FLAG_ONELINE) {
|
||||
pctx = ASN1_PCTX_new();
|
||||
if (pctx != NULL) { /* Print anyway if malloc failed */
|
||||
ASN1_PCTX_set_flags(pctx, ASN1_PCTX_FLAGS_SHOW_ABSENT);
|
||||
ASN1_PCTX_set_str_flags(pctx, get_nameopt());
|
||||
ASN1_PCTX_set_nm_flags(pctx, get_nameopt());
|
||||
}
|
||||
}
|
||||
CMS_ContentInfo_print_ctx(out, cms, 0, pctx);
|
||||
ASN1_PCTX_free(pctx);
|
||||
}
|
||||
} else if (outformat == FORMAT_SMIME) {
|
||||
if (to)
|
||||
BIO_printf(out, "To: %s%s", to, mime_eol);
|
||||
|
|
Loading…
Reference in New Issue