Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -quiet option to pkcs7 for -print_certs #17708

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions apps/pkcs7.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
typedef enum OPTION_choice {
OPT_COMMON,
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_NOOUT,
OPT_TEXT, OPT_PRINT, OPT_PRINT_CERTS, OPT_ENGINE,
OPT_PROV_ENUM
OPT_TEXT, OPT_PRINT, OPT_PRINT_CERTS, OPT_QUIET,
OPT_ENGINE, OPT_PROV_ENUM
} OPTION_CHOICE;

const OPTIONS pkcs7_options[] = {
Expand All @@ -46,6 +46,8 @@ const OPTIONS pkcs7_options[] = {
{"print", OPT_PRINT, '-', "Print out all fields of the PKCS7 structure"},
{"print_certs", OPT_PRINT_CERTS, '-',
"Print_certs print any certs or crl in the input"},
{"quiet", OPT_QUIET, '-',
"When used with -print_certs, it produces a clean output"},
rferrandop marked this conversation as resolved.
Show resolved Hide resolved

OPT_PROV_OPTIONS,
{NULL}
Expand All @@ -58,7 +60,7 @@ int pkcs7_main(int argc, char **argv)
BIO *in = NULL, *out = NULL;
int informat = FORMAT_PEM, outformat = FORMAT_PEM;
char *infile = NULL, *outfile = NULL, *prog;
int i, print_certs = 0, text = 0, noout = 0, p7_print = 0, ret = 1;
int i, print_certs = 0, text = 0, noout = 0, p7_print = 0, quiet = 0, ret = 1;
OPTION_CHOICE o;
OSSL_LIB_CTX *libctx = app_get0_libctx();

Expand Down Expand Up @@ -100,6 +102,9 @@ int pkcs7_main(int argc, char **argv)
case OPT_PRINT_CERTS:
print_certs = 1;
break;
case OPT_QUIET:
quiet = 1;
break;
case OPT_ENGINE:
e = setup_engine(opt_arg(), 0);
break;
Expand Down Expand Up @@ -171,7 +176,7 @@ int pkcs7_main(int argc, char **argv)
x = sk_X509_value(certs, i);
if (text)
X509_print(out, x);
else
else if (!quiet)
dump_cert_text(out, x);

if (!noout)
Expand Down
6 changes: 6 additions & 0 deletions doc/man1/openssl-pkcs7.pod.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ B<openssl> B<pkcs7>
[B<-out> I<filename>]
[B<-print>]
[B<-print_certs>]
[B<-quiet>]
[B<-text>]
[B<-noout>]
{- $OpenSSL::safe::opt_engine_synopsis -}{- $OpenSSL::safe::opt_provider_synopsis -}
Expand Down Expand Up @@ -63,6 +64,11 @@ Print out the full PKCS7 object.
Prints out any certificates or CRLs contained in the file. They are
preceded by their subject and issuer names in one line format.

=item B<-quiet>

When used with -print_certs, prints out just the PEM-encoded
certificates without any other output.

=item B<-text>

Prints out certificate details in full rather than just subject and
Expand Down