From: Dmitry Eremin-Solenikov Date: Wed, 21 Nov 2018 17:05:20 +0000 (+0300) Subject: certtool: don't output pkcs12 information to stderr X-Git-Tag: gnutls_3_6_5~12^2~2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=f9874f9feac63ea25d462d15ccdeb2d2f883298e;p=thirdparty%2Fgnutls.git certtool: don't output pkcs12 information to stderr Print all pkcs12-info output to outfile, rather than stderr. Signed-off-by: Dmitry Eremin-Solenikov --- diff --git a/src/certtool.c b/src/certtool.c index a45efdf7b7..e32541319f 100644 --- a/src/certtool.c +++ b/src/certtool.c @@ -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); diff --git a/tests/cert-tests/data/key-corpus-rc2-1.p12.out b/tests/cert-tests/data/key-corpus-rc2-1.p12.out index 534b796546..6246ca31b9 100644 --- a/tests/cert-tests/data/key-corpus-rc2-1.p12.out +++ b/tests/cert-tests/data/key-corpus-rc2-1.p12.out @@ -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