From: Nikos Mavrogiannopoulos Date: Sun, 8 Jan 2012 12:21:23 +0000 (+0100) Subject: certtool --outder option now works for private keys as well. X-Git-Tag: gnutls-3_0_12~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1f79baf66a79227246160ea49a805f60d5d6b68;p=thirdparty%2Fgnutls.git certtool --outder option now works for private keys as well. --- diff --git a/NEWS b/NEWS index df33d1b2df..167e6b15c0 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,9 @@ See the end for copying conditions. * Version 3.0.12 (unreleased) +** certtool: --outder option now works for private +keys as well. + ** libgnutls: Corrected memory leak in DH parameter generation. diff --git a/src/certtool.c b/src/certtool.c index 11de1f995e..558bbfaf26 100644 --- a/src/certtool.c +++ b/src/certtool.c @@ -275,7 +275,8 @@ print_private_key (gnutls_x509_privkey_t key) if (!key) return; - privkey_info_int(key); + if (info.outcert_format == GNUTLS_X509_FMT_PEM) + privkey_info_int(key); if (!info.pkcs8) { @@ -1788,7 +1789,8 @@ privkey_info (void) if (ret < 0) error (EXIT_FAILURE, 0, "import error: %s", gnutls_strerror (ret)); - privkey_info_int (key); + if (info.outcert_format == GNUTLS_X509_FMT_PEM) + privkey_info_int (key); ret = gnutls_x509_privkey_verify_params (key); if (ret < 0) @@ -1802,11 +1804,11 @@ privkey_info (void) } size = buffer_size; - ret = gnutls_x509_privkey_export (key, GNUTLS_X509_FMT_PEM, buffer, &size); + ret = gnutls_x509_privkey_export (key, info.outcert_format, buffer, &size); if (ret < 0) error (EXIT_FAILURE, 0, "export error: %s", gnutls_strerror (ret)); - fprintf (outfile, "\n%s\n", buffer); + fwrite (buffer, 1, size, outfile); gnutls_x509_privkey_deinit (key); }