]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
certtool: don't output pkcs12 information to stderr
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Wed, 21 Nov 2018 17:05:20 +0000 (20:05 +0300)
committerDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Mon, 26 Nov 2018 13:56:34 +0000 (16:56 +0300)
Print all pkcs12-info output to outfile, rather than stderr.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
src/certtool.c
tests/cert-tests/data/key-corpus-rc2-1.p12.out

index a45efdf7b755f572263bd38f24da74ab31c432fb..e32541319f7a1895fda6512af4113fff24d0dfe5 100644 (file)
@@ -3273,7 +3273,7 @@ static void print_bag_data(gnutls_pkcs12_bag_t bag)
                        app_exit(1);
                }
 
-               fprintf(stderr, "\tType: %s\n", BAGTYPE(type));
+               fprintf(outfile, "\tType: %s\n", BAGTYPE(type));
 
                result = gnutls_pkcs12_bag_get_data(bag, i, &cdata);
                if (result < 0) {
@@ -3282,12 +3282,9 @@ static void print_bag_data(gnutls_pkcs12_bag_t bag)
                        app_exit(1);
                }
 
-               if (type == GNUTLS_BAG_PKCS8_ENCRYPTED_KEY) {
-                       if (outcert_format == GNUTLS_X509_FMT_DER)
-                               pkcs8_info_int(&cdata, GNUTLS_X509_FMT_DER, 1, stderr, "\t");
-                       else
-                               pkcs8_info_int(&cdata, GNUTLS_X509_FMT_DER, 1, outfile, "\t");
-               }
+               if (type == GNUTLS_BAG_PKCS8_ENCRYPTED_KEY &&
+                   outcert_format == GNUTLS_X509_FMT_PEM)
+                       pkcs8_info_int(&cdata, GNUTLS_X509_FMT_DER, 1, outfile, "\t");
 
                name = NULL;
                result =
@@ -3505,9 +3502,9 @@ void pkcs12_info(common_info_st * cinfo)
                }
 
                if (result == GNUTLS_BAG_ENCRYPTED) {
-                       fprintf(stderr, "\tType: %s\n", BAGTYPE(result));
-                       pkcs12_bag_enc_info(bag, stderr);
-                       fprintf(stderr, "\n\tDecrypting...\n");
+                       fprintf(outfile, "\tType: %s\n", BAGTYPE(result));
+                       pkcs12_bag_enc_info(bag, outfile);
+                       fprintf(outfile, "\n\tDecrypting...\n");
 
                        result = gnutls_pkcs12_bag_decrypt(bag, pass);
 
index 534b7965465a1a45881db213bbb4f4126e5f8ad2..6246ca31b9df1a08b6f1c8f18233888f2274b462 100644 (file)
@@ -5,8 +5,13 @@ MAC info:
        Iteration count: 2048
 
 BAG #0
+       Type: Encrypted
+       Schema: unsupported (1.2.840.113549.1.5.13)
+
+       Decrypting...
 BAG #1
        Elements: 1
+       Type: PKCS #8 Encrypted key
 PKCS #8 information:
        Schema: unsupported (1.2.840.113549.1.5.13/1.2.840.113549.3.2)
        Friendly name: localhost