apps/crl: Print just the hash value if printing just hash
authorTomas Mraz <tomas@openssl.org>
Mon, 15 Mar 2021 12:53:10 +0000 (13:53 +0100)
committerTomas Mraz <tomas@openssl.org>
Wed, 17 Mar 2021 11:49:10 +0000 (12:49 +0100)
This partially reverts the output format change for
openssl crl -hash output.

Fixes #14546

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14553)

apps/crl.c

index 1f12e24a4ba2cd46cb636984237aa2cd9d27411d..e2ed9588e665daeaa534dbd01745bf9b8eab6f85 100644 (file)
@@ -308,15 +308,19 @@ int crl_main(int argc, char **argv)
                     X509_NAME_hash_ex(X509_CRL_get_issuer(x), app_get0_libctx(),
                                       app_get0_propq(), &ok);
 
-                BIO_printf(bio_out, "issuer name hash=");
-                if (ok)
+                if (num > 1)
+                    BIO_printf(bio_out, "issuer name hash=");
+                if (ok) {
                     BIO_printf(bio_out, "%08lx\n", hash_value);
-                else
+                } else {
                     BIO_puts(bio_out, "<ERROR>");
+                    goto end;
+                }
             }
 #ifndef OPENSSL_NO_MD5
             if (hash_old == i) {
-                BIO_printf(bio_out, "issuer name old hash=");
+                if (num > 1)
+                    BIO_printf(bio_out, "issuer name old hash=");
                 BIO_printf(bio_out, "%08lx\n",
                            X509_NAME_hash_old(X509_CRL_get_issuer(x)));
             }