talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 69d37da86c46452c76ef04defbb30264706f7c4b
parent bbcd0da4f47dd471ee1e4439731ac55fa3940422
Author: Colin Leroy <colin@colino.net>
Date:   Wed, 17 Oct 2012 07:52:49 +0000

2012-10-17 [colin]	3.8.1cvs100

	* src/common/ssl_certificate.c
		Fix bug #2759, "Error messages regarding bad
		client certificates are less than helpful"
		Based on patch by bug reporter.

Diffstat:
MChangeLog | 7+++++++
MPATCHSETS | 1+
Mconfigure.ac | 2+-
Msrc/common/ssl_certificate.c | 31+++++++++++++++++++++++++------
4 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,10 @@ +2012-10-17 [colin] 3.8.1cvs100 + + * src/common/ssl_certificate.c + Fix bug #2759, "Error messages regarding bad + client certificates are less than helpful" + Based on patch by bug reporter. + 2012-10-13 [paul] 3.8.1cvs99 * src/common/ssl_certificate.c diff --git a/PATCHSETS b/PATCHSETS @@ -4474,3 +4474,4 @@ ( cvs diff -u -r 1.9.2.60 -r 1.9.2.61 src/common/defs.h; ) > 3.8.1cvs97.patchset ( cvs diff -u -r 1.382.2.616 -r 1.382.2.617 src/compose.c; cvs diff -u -r 1.14.2.34 -r 1.14.2.35 src/grouplistdialog.c; cvs diff -u -r 1.179.2.267 -r 1.179.2.268 src/imap.c; cvs diff -u -r 1.2.2.36 -r 1.2.2.37 src/news_gtk.c; cvs diff -u -r 1.49.2.153 -r 1.49.2.154 src/procmime.c; cvs diff -u -r 1.150.2.130 -r 1.150.2.131 src/procmsg.c; cvs diff -u -r 1.36.2.206 -r 1.36.2.207 src/common/utils.c; cvs diff -u -r 1.20.2.81 -r 1.20.2.82 src/common/utils.h; cvs diff -u -r 1.1.4.122 -r 1.1.4.123 src/etpan/imap-thread.c; ) > 3.8.1cvs98.patchset ( cvs diff -u -r 1.4.2.44 -r 1.4.2.45 src/common/ssl_certificate.c; ) > 3.8.1cvs99.patchset +( cvs diff -u -r 1.4.2.45 -r 1.4.2.46 src/common/ssl_certificate.c; ) > 3.8.1cvs100.patchset diff --git a/configure.ac b/configure.ac @@ -12,7 +12,7 @@ MINOR_VERSION=8 MICRO_VERSION=1 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=99 +EXTRA_VERSION=100 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/common/ssl_certificate.c b/src/common/ssl_certificate.c @@ -34,6 +34,7 @@ #include <stdio.h> #include <glib.h> #include <glib/gi18n.h> +#include <errno.h> #ifdef G_OS_WIN32 # include <winsock2.h> #else @@ -273,14 +274,16 @@ static gnutls_pkcs12_t gnutls_d2i_PKCS12_fp(FILE *fp, int format) struct stat s; int r; if (fstat(fileno(fp), &s) < 0) { - perror("fstat"); + log_error(LOG_PROTOCOL, _("Cannot stat P12 certificate file (%s)\n"), + strerror(errno)); return NULL; } tmp.data = malloc(s.st_size); memset(tmp.data, 0, s.st_size); tmp.size = s.st_size; if (fread (tmp.data, 1, s.st_size, fp) < s.st_size) { - perror("fread"); + log_error(LOG_PROTOCOL, _("Cannot read P12 certificate file (%s)\n"), + strerror(errno)); free(tmp.data); return NULL; } @@ -288,7 +291,8 @@ static gnutls_pkcs12_t gnutls_d2i_PKCS12_fp(FILE *fp, int format) gnutls_pkcs12_init(&p12); if ((r = gnutls_pkcs12_import(p12, &tmp, (format == 0)?GNUTLS_X509_FMT_DER:GNUTLS_X509_FMT_PEM,0)) < 0) { - g_warning("p12 import failed: %s\n", gnutls_strerror(r)); + log_error(LOG_PROTOCOL, _("Cannot import P12 certificate file (%s)\n"), + gnutls_strerror(r)); gnutls_pkcs12_deinit(p12); p12 = NULL; } @@ -655,9 +659,13 @@ gnutls_x509_crt ssl_certificate_get_x509_from_pem_file(const gchar *file) x509 = gnutls_d2i_X509_fp(fp, 1); fclose(fp); return x509; + } else { + log_error(LOG_PROTOCOL, _("Cannot open certificate file %s: %s\n"), + file, strerror(errno)); } } else { - log_error(LOG_PROTOCOL, _("Cannot open certificate file %s\n"), file); + log_error(LOG_PROTOCOL, _("Certificate file %s missing (%s)\n"), + file, strerror(errno)); } return NULL; } @@ -674,9 +682,13 @@ gnutls_x509_privkey ssl_certificate_get_pkey_from_pem_file(const gchar *file) key = gnutls_d2i_key_fp(fp, 1); fclose(fp); return key; + } else { + log_error(LOG_PROTOCOL, _("Cannot open key file %s (%s)\n"), + file, strerror(errno)); } } else { - log_error(LOG_PROTOCOL, _("Cannot open key file %s\n"), file); + log_error(LOG_PROTOCOL, _("Key file %s missing (%s)\n"), file, + strerror(errno)); } return NULL; } @@ -822,9 +834,16 @@ void ssl_certificate_get_x509_and_pkey_from_p12_file(const gchar *file, const gc if (fp) { p12 = gnutls_d2i_PKCS12_fp(fp, 0); fclose(fp); + if (!p12) { + log_error(LOG_PROTOCOL, _("Failed to read P12 certificate file %s\n"), file); + } + } else { + log_error(LOG_PROTOCOL, _("Cannot open P12 certificate file %s (%s)\n"), + file, strerror(errno)); } } else { - log_error(LOG_PROTOCOL, _("Cannot open certificate file %s\n"), file); + log_error(LOG_PROTOCOL, _("P12 Certificate file %s missing (%s)\n"), file, + strerror(errno)); } if (p12 != NULL) { if ((r = parse_pkcs12(p12, password, pkey, x509)) == 0) {