[Commits] ssl_certificate.c 1.4.2.45 1.4.2.46

colin at claws-mail.org colin at claws-mail.org
Wed Oct 17 09:52:49 CEST 2012


Update of /home/claws-mail/claws/src/common
In directory srv:/tmp/cvs-serv20368/src/common

Modified Files:
      Tag: gtk2
	ssl_certificate.c 
Log Message:
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.

Index: ssl_certificate.c
===================================================================
RCS file: /home/claws-mail/claws/src/common/ssl_certificate.c,v
retrieving revision 1.4.2.45
retrieving revision 1.4.2.46
diff -u -d -r1.4.2.45 -r1.4.2.46
--- ssl_certificate.c	13 Oct 2012 09:45:58 -0000	1.4.2.45
+++ ssl_certificate.c	17 Oct 2012 07:52:47 -0000	1.4.2.46
@@ -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 @@
 	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 @@
 	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 @@
 			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 @@
 			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 @@
 		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) {



More information about the Commits mailing list